-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
We're hitting a bug where generated code doesn't compile when using API specs referencing each other. This may or may not be related to #695, so I'm opening a separate issue just to be sure.
The setup is this (also available at https://github.com/maragudk/oapi-codegen-bug):
- An
api.yamlspec references a path in acommon.yamlspec. - In
common.yaml, a path/pingreferences a schemaPingResponsein the same file.
When the spec is generated for api.yaml, PingResponse doesn't have the externalRef0 package name prefix, and so the generated code can't compile.
This is with v2 of oapi-codegen.
api.yaml
version: "3.0.0"
paths:
/ping:
$ref: "common.yaml#/paths/~1ping"config.yaml
package: api
generate:
gin-server: true
embedded-spec: true
strict-server: true
models: true
import-mapping:
common.yaml: github.com/maragudk/oapi-codegen-bug/oapi/common
output: api.gen.gocommon.yaml
version: "3.0.0"
paths:
/ping:
get:
responses:
200:
content:
application/json:
schema:
$ref: "#/components/schemas/PingResponse"
components:
schemas:
PingResponse:
type: object
properties:
message:
type: stringconfig.yaml
package: common
generate:
gin-server: true
embedded-spec: true
strict-server: true
models: true
output: common.gen.goMetadata
Metadata
Assignees
Labels
No labels