Skip to content

External reference not properly prefixed in generated response types #2308

@cdevienne

Description

@cdevienne

Summary

When using import-mapping with external OpenAPI files, the generated code references response
types without the external package prefix.

Expected Behavior

Response types from external files should be prefixed with the mapped package name.

Actual Behavior

The generated code references the type directly without the package prefix.

Minimal Reproduction

api.yaml:

paths:
  /v1/version:
    $ref: './types.yaml#/components/pathitems/VersionOperations'

types.yaml:

components:
  pathitems:
    VersionOperations:
      get:
        responses:
          '200':
            $ref: '#/components/responses/VersionGetResponse'

  responses:
    VersionGetResponse: 
      content:
        application/json:
          schema:
            type: string

config.yaml:

package: api
output: api.gen.go
generate:
  models: true
  gorilla-server: true
  strict-server: true
import-mapping:
  ./types.yaml: "types"

Generated Output (Incorrect)

type GetV1Version200JSONResponse struct{ VersionGetResponseJSONResponse }

Expected Output

type GetV1Version200JSONResponse struct{ externalRef0.VersionGetResponseJSONResponse }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions