Skip to content

x-go-type-name isn't working when used in responses section #1306

@soeenplop

Description

@soeenplop

When "x-go-type-name" is set for an object type within the responses-section of an operation definition (not in the components-section), the type definition is not included in the generated file.

Example:

info:
  version: '0.0.1'
  title: example
  description: |
    Make sure that recursive types are handled properly
paths:
  /example:
    get:
      operationId: exampleGet
      responses:
        '200':
          description: "OK"
          content:
            'application/json':
              schema:
                type: object
                x-go-type-name: SomeObject
                properties:
                  name:
                    type: string

Executing oapi-codegen -package openapi_test -generate types -o openapi.gen.go openapi.yaml results in an empty file:

//
// Code generated by github.com/deepmap/oapi-codegen version (devel) DO NOT EDIT.
package openapi_test

What I would expect instead, is:

//
// Code generated by github.com/deepmap/oapi-codegen version (devel) DO NOT EDIT.
package openapi_test

// SomeType defines parameters for ExampleGet.
type SomeType struct {
	Name *string `json:"name,omitempty"`
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions