Skip to content

import-mapping and embedded-spec produces swagger doc that cannot be loaded #1055

@yspotts

Description

@yspotts

I have two openapi docs. One references a model in the other one. I have configured oapi-codegen as follows:

package: packageB
generate:
  models: true
  embedded-spec: true
output-options:
  skip-prune: true
import-mapping:
  ./specA.yml: github.com/org/packageA/
output: pkg/api/packageB/v1/types.gen.go
compatibility:
  old-aliasing: true
  old-merge-schemas: true
  disable-flatten-additional-properties: true

The openapi spec for packageB contains a reference such as:

   $ref: './specA.yml#/components/schemas/Entity'

The server, client code and the types are generated without an issue.

However, if I try and load the embedded swagger spec:

swagger, err := packageB.GetSwagger()

it throws an error such as:

failed to resolve "Entity" in fragment in URI: "#/components/schemas/Entity": map key "Entity" not found

It seems that the external reference to the other apidoc is lost in the embedded spec.

Is this by design? Is there a configuration setting perhaps I am missing?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions