Skip to content

Commit 2a1c4b1

Browse files
authored
document union behaviour of XyzRef.s (#468)
1 parent 389b5e2 commit 2a1c4b1

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.github/workflows/go.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ jobs:
6464
- if: runner.os == 'Linux'
6565
run: git --no-pager diff && [[ $(git --no-pager diff --name-only | wc -l) = 0 ]]
6666

67-
- run: go test -count=10 -v -run TestIssue356 ./routers
6867
- run: go test ./...
6968
- run: go test -v -run TestRaceyPatternSchema -race ./...
7069
env:

openapi3/refs.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ type Ref struct {
1212
Ref string `json:"$ref" yaml:"$ref"`
1313
}
1414

15+
// CallbackRef represents either a Callback or a $ref to a Callback.
16+
// When serializing and both fields are set, Ref is preferred over Value.
1517
type CallbackRef struct {
1618
Ref string
1719
Value *Callback
@@ -43,6 +45,8 @@ func (value CallbackRef) JSONLookup(token string) (interface{}, error) {
4345
return ptr, err
4446
}
4547

48+
// ExampleRef represents either a Example or a $ref to a Example.
49+
// When serializing and both fields are set, Ref is preferred over Value.
4650
type ExampleRef struct {
4751
Ref string
4852
Value *Example
@@ -74,6 +78,8 @@ func (value ExampleRef) JSONLookup(token string) (interface{}, error) {
7478
return ptr, err
7579
}
7680

81+
// HeaderRef represents either a Header or a $ref to a Header.
82+
// When serializing and both fields are set, Ref is preferred over Value.
7783
type HeaderRef struct {
7884
Ref string
7985
Value *Header
@@ -105,6 +111,8 @@ func (value HeaderRef) JSONLookup(token string) (interface{}, error) {
105111
return ptr, err
106112
}
107113

114+
// LinkRef represents either a Link or a $ref to a Link.
115+
// When serializing and both fields are set, Ref is preferred over Value.
108116
type LinkRef struct {
109117
Ref string
110118
Value *Link
@@ -125,6 +133,8 @@ func (value *LinkRef) Validate(ctx context.Context) error {
125133
return foundUnresolvedRef(value.Ref)
126134
}
127135

136+
// ParameterRef represents either a Parameter or a $ref to a Parameter.
137+
// When serializing and both fields are set, Ref is preferred over Value.
128138
type ParameterRef struct {
129139
Ref string
130140
Value *Parameter
@@ -156,6 +166,8 @@ func (value ParameterRef) JSONLookup(token string) (interface{}, error) {
156166
return ptr, err
157167
}
158168

169+
// ResponseRef represents either a Response or a $ref to a Response.
170+
// When serializing and both fields are set, Ref is preferred over Value.
159171
type ResponseRef struct {
160172
Ref string
161173
Value *Response
@@ -187,6 +199,8 @@ func (value ResponseRef) JSONLookup(token string) (interface{}, error) {
187199
return ptr, err
188200
}
189201

202+
// RequestBodyRef represents either a RequestBody or a $ref to a RequestBody.
203+
// When serializing and both fields are set, Ref is preferred over Value.
190204
type RequestBodyRef struct {
191205
Ref string
192206
Value *RequestBody
@@ -218,6 +232,8 @@ func (value RequestBodyRef) JSONLookup(token string) (interface{}, error) {
218232
return ptr, err
219233
}
220234

235+
// SchemaRef represents either a Schema or a $ref to a Schema.
236+
// When serializing and both fields are set, Ref is preferred over Value.
221237
type SchemaRef struct {
222238
Ref string
223239
Value *Schema
@@ -256,6 +272,8 @@ func (value SchemaRef) JSONLookup(token string) (interface{}, error) {
256272
return ptr, err
257273
}
258274

275+
// SecuritySchemeRef represents either a SecurityScheme or a $ref to a SecurityScheme.
276+
// When serializing and both fields are set, Ref is preferred over Value.
259277
type SecuritySchemeRef struct {
260278
Ref string
261279
Value *SecurityScheme

0 commit comments

Comments
 (0)