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.yaml spec references a path in a common.yaml spec.
- In
common.yaml, a path /ping references a schema PingResponse in 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.go
common.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: string
config.yaml
package: common
generate:
gin-server: true
embedded-spec: true
strict-server: true
models: true
output: common.gen.go
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):
api.yamlspec references a path in acommon.yamlspec.common.yaml, a path/pingreferences a schemaPingResponsein the same file.When the spec is generated for
api.yaml,PingResponsedoesn't have theexternalRef0package name prefix, and so the generated code can't compile.This is with v2 of oapi-codegen.
api.yaml
config.yaml
common.yaml
config.yaml