openapi-python-client icon indicating copy to clipboard operation
openapi-python-client copied to clipboard

Array index in $ref

Open Yamakaky opened this issue 4 years ago • 0 comments

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

Yamakaky avatar Jul 06 '21 07:07 Yamakaky