Skip to content

Commit

Permalink
document union behaviour of XyzRef.s (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
fenollp committed Dec 20, 2021
1 parent 389b5e2 commit 2a1c4b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 0 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
- if: runner.os == 'Linux'
run: git --no-pager diff && [[ $(git --no-pager diff --name-only | wc -l) = 0 ]]

- run: go test -count=10 -v -run TestIssue356 ./routers
- run: go test ./...
- run: go test -v -run TestRaceyPatternSchema -race ./...
env:
Expand Down
18 changes: 18 additions & 0 deletions openapi3/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type Ref struct {
Ref string `json:"$ref" yaml:"$ref"`
}

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

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

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

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

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

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

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

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

// SecuritySchemeRef represents either a SecurityScheme or a $ref to a SecurityScheme.
// When serializing and both fields are set, Ref is preferred over Value.
type SecuritySchemeRef struct {
Ref string
Value *SecurityScheme
Expand Down

0 comments on commit 2a1c4b1

Please sign in to comment.