Skip to content

Generated code references missing enum type #467

Description

@AlbinoDrought
openapi: 3.0.2

servers:
  - url: /api

info:
  title: Demo
  version: 0.0.1

paths:
  /demo:
    get:
      responses:
        200:
          $ref: "#/components/responses/DemoBrokenResponse"

components:
  responses:
    DemoBrokenResponse:
      description: |
        Generated struct tries to reference an enum,
        but no type gets generated for that enum.
        Code does not compile.
      content:
        application/json:
          schema:
            type: object
            required: [some_property]
            properties:
              some_property:
                type: string
                enum: ["Some Value", "Some Other Value"]

Running oapi-codegen -o repro.gen.go -package openapi -generate types repro.yml gives you

// Package openapi provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen version v1.8.3 DO NOT EDIT.
package openapi

// DemoBrokenResponse defines model for DemoBrokenResponse.
type DemoBrokenResponse struct {
	SomeProperty DemoBrokenResponseSomeProperty `json:"some_property"`
}

The DemoBrokenResponseSomeProperty type is missing.

image

Running v1.8.3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions