You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Include an embedded struct in a response, label it with swagger:allOf, and expect to see a $ref in the generated schema.
Actual Behavior
The fields are listed as properties
Swagger specification
Note the allOf section for userResponse
This is the actual generated spec:
responses:
baseResponse:
description: ""headers:
error:
description: An error message describing what went wrongtype: stringok:
description: Whether the request was successful or nottype: booleanuserResponse:
description: ""schema:
allOf:
- properties:
error:
description: An error message describing what went wrongtype: stringok:
description: Whether the request was successful or nottype: booleantype: object
- properties:
user:
$ref: '#/definitions/User'type: object
And this is what should be generated:
responses:
baseResponse:
description: ""headers:
error:
description: An error message describing what went wrongtype: stringok:
description: Whether the request was successful or nottype: booleanuserResponse:
description: ""schema:
allOf:
- $ref: '#/responses/baseResponse'
- properties:
user:
$ref: '#/definitions/User'type: object
Steps to reproduce
// swagger:response baseResponsetypeBaseResponsestruct {
// An error message describing what went wrongErrorstring`json:"error,omitempty"`// Whether the request was successful or notOKbool`json:"ok"`
}
// swagger:response userResponsetypeUserResponsestruct {
// in: bodyBodystruct {
// swagger:allOfBaseResponseUserUser`json:"user"`
}
}
Environment
swagger version: v0.29.0
go version: go1.18 linux/amd64
OS: Pop!_OS 21.04
The text was updated successfully, but these errors were encountered:
Kangaroux
changed the title
generate: allOf in response body doesn't use $ref
generate: allOf in response doesn't use $ref
Apr 14, 2022
Expected Behavior
Include an embedded struct in a response, label it with
swagger:allOf
, and expect to see a$ref
in the generated schema.Actual Behavior
The fields are listed as properties
Swagger specification
Note the
allOf
section foruserResponse
This is the actual generated spec:
And this is what should be generated:
Steps to reproduce
Environment
swagger version: v0.29.0
go version: go1.18 linux/amd64
OS: Pop!_OS 21.04
The text was updated successfully, but these errors were encountered: