Skip to content

Array index in $ref #450

@Yamakaky

Description

@Yamakaky

Describe the bug
The generator doesn't seem to support array indices in $ref.

To Reproduce

openapi-python-client generate --path /tmp/bug.json
Generating bug-client
Warning(s) encountered while generating. Client was generated, but some pieces may be missing

ERROR parsing POST /alarms within default. Endpoint will not be generated.

Could not find reference in parsed models or enums

Reference(ref='#/paths/~1alarms/post/parameters/0/schema')

Expected behavior
The following $ref should resolve to the parameter's schema.

OpenAPI Spec File

{
  "openapi": "3.0.1",
  "info": {
    "title": "Bug",
    "version": "1.0"
  },
  "paths": {
    "/alarms": {
      "post": {
        "parameters": [
          {
            "name": "X-ID",
            "in": "header",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "$ref": "#/paths/~1alarms/post/parameters/0/schema"
                    }
                }
              }
            }
          }
        },
        "responses": {
        }
      }
    }
  }
}

Desktop (please complete the following information):

  • OS: Ubuntu
  • Python Version: 3.9
  • openapi-python-client version 0.9.2

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