-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Description
Summary: the response object in a the generated client code does not honor the $ref of the of response, if the $ref is referring to content in a different spec file.
Setup:
PackageA/config.yaml
package: packageA
generate:
models: true
embedded-spec: true
client: true
output-options:
skip-prune: true
import-mapping:
../packageB/spec.yaml: github.com/deepmap/oapi-codegen/internal/test/externalref/packageB
skip-fmt: true
output: externalref.gen.go
PackageA/spec.yaml
paths:
/api/test:
post:
operationId: TestApi
summary: test
description: test
responses:
'200':
description: 'success'
$ref: ../packageB/spec.yaml#/components/responses/ResponseC
PackageB/spec.yaml
components:
schemas:
ObjectB:
type: object
properties:
name:
type: boolean
responses:
ResponseC:
description: ResponseC
content:
application/json:
schema:
$ref: '#/components/schemas/ObjectB'
Generated client code for packageA
//go:generate go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen --config=config.yaml spec.yaml
type TestApiResponse struct {
Body []byte
HTTPResponse *http.Response
JSON200 *ObjectB
}
Expected:
type TestApiResponse struct {
Body []byte
HTTPResponse *http.Response
JSON200 *externalRef0.ObjectB
}
I've also attached a modified version of the internal\test\externalref code that demonstrates this issue.
externalref.zip
Metadata
Metadata
Assignees
Labels
No labels