Skip to content

Commit

Permalink
Enable $refs in response headers of OpenAPI3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
blaubaer committed May 22, 2024
1 parent 28402d8 commit 4cfef9d
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 4cfef9d

Please sign in to comment.