oapi-codegen
oapi-codegen copied to clipboard
Nested types included by local $ref in external references are omitted from the swaggerSpec
The generated swaggerSpec does not contain nested types when the nested type is defined in an external reference, and included there via $ref
.
I have modified the externalref test to demonstrate it, which you can see here:
https://github.com/marcparadise/oapi-codegen/pull/1
It changes packageB/spec.yaml
to look like:
components:
schemas:
ObjectB:
properties:
name:
type: string
nested:
$ref: "#/components/schemas/ObjectC"
ObjectC:
properties:
name:
type: string
After go generate
, running the externalref test results in:
- FAIL: TestGetSwagger (0.00s)
imports_test.go:27:
Error Trace: /home/username/projects/oapi-codegen/internal/test/externalref/imports_test.go:27
Error: Expected nil, but got: &fmt.wrapError{msg:"failed to resolve \"ObjectC\" in fragment in URI: \"#/components/schemas/ObjectC\": map key \"ObjectC\" not found", err:(*errors.errorString)(0xc000277b90)}
Test: TestGetSwagger
FAIL
It's worth mentioning that in this example, a struct for ObjectC
is also not generated. In my real-world issue that led to this, its equivalent is getting generated. I haven't explored this further yet, since this example correctly reproduces the symptom.
Also met this issue. Very annoyng for me.
Same here
Looks the same as what I also met: https://github.com/deepmap/oapi-codegen/issues/860
I have the same problem
error generating code: error creating operation definitions: error describing global parameters for /{version}/account/{account_req_uuid}/asset/: error generating type for param (account_req_uuid): parameter 'account_req_uuid' has no schema or content
with ref keyword
Any updates or workarounds on this issue?