Skip to content

Endpoint response objects not being generated #1339

Description

@Tanz0rz

oapi-codegen does not generate response objects the way I expect:

Here is my endpoint:

"/v5.2/items": {
  "get": {
    "operationId": "ItemsController_getItems",
    "summary": "List of items available in the system",
    "parameters": [],
    "responses": {
      "200": {
        "description": "All supported items",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "items": {
                  "type": "object",
                  "properties": {
                    "item1": {
                      "$ref": "#/components/schemas/ItemDetail"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "tags": ["General"]
  }
}

When I run oapi-codegen -generate types, I would expect there to be a response object created like this:

type ItemsResponse struct {
	Items map[string]ItemDetail `json:"items"`
}

But right now, only ItemDetail is being created and I am manually creating the proper response object myself.

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