Skip to content

Commit

Permalink
Merge pull request #112 from echocat/oa31-refs-in-response-headers
Browse files Browse the repository at this point in the history
fix: Enable `$ref`s in response headers of OpenAPI3.1
  • Loading branch information
vearutop authored Jun 25, 2024
2 parents 91c2f80 + 4cfef9d commit b19848c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
24 changes: 22 additions & 2 deletions openapi31/entities.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions openapi31/entities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,44 @@ func TestSpec_UnmarshalYAML(t *testing.T) {
refl := openapi31.NewReflector()
require.NoError(t, refl.Spec.UnmarshalYAML(bytes))
}

func TestSpec_UnmarshalYAML_refsInResponseHeaders(t *testing.T) {
var s openapi31.Spec

spec := `openapi: 3.1.0f
info:
description: description
license:
name: Apache-2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
title: title
version: 2.0.0
servers:
- url: /v2
paths:
/user:
put:
summary: updates the user by id
operationId: UpdateUser
requestBody:
content:
application/json:
schema:
type: string
description: Updated user object
required: true
responses:
"404":
description: User not found
headers:
Cache-Control:
$ref: '#/components/headers/CacheControl'
components:
headers:
CacheControl:
schema:
type: string
`

require.NoError(t, s.UnmarshalYAML([]byte(spec)))
}

0 comments on commit b19848c

Please sign in to comment.