oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

enum in components/responses generate incomplete code

Open knoguchi opened this issue 2 years ago • 1 comments

Edit: it seems #1239 is the same issue. #972 and #1192 are possibly same issue.

Generated code for enum in the components/responses refers undefined type.

Here is the minimal spec to reproduce the problem.

paths:
  /books:
    get:
      responses:
        '200':
          $ref: '#/components/responses/BookList'

components:
  responses:
    BookList:
      description: list of books
      content:
        application/json:
          schema:
            properties:
              genre:
                type: string
                enum:
                  - fiction
                  - scifi

Generated code uses BookListGenre type but it doesn't exist.

// BookList defines model for BookList.
type BookList struct {
	Genre *BookListGenre `json:"genre,omitempty"`
}

knoguchi avatar Oct 07 '23 00:10 knoguchi

I assume this hasn't been solved?

anthops avatar Oct 18 '25 19:10 anthops