Azure / autorest

OpenAPI (f.k.a Swagger) Specification code generator. Supports C#, PowerShell, Go, Java, Node.js, TypeScript, Python
MIT License
4.61k stars 737 forks source link

Unable to generate python from vsts-rest-api-specs #4641

Closed jabbera closed 2 years ago

jabbera commented 2 years ago

Before filling a bug

Describe the bug When attempting to generate python code from the azure devops specs I get the following error:

error   | PreCheck/AllOfTypeDifferent | Schema 'JsonPatchDocument' has an allOf reference to 'components·5lk5um·schemas·jsonpatchdocument·allof·0' but those schema have different types:
  - JsonPatchDocument: object
  - components·5lk5um·schemas·jsonpatchdocument·allof·0: array
    - file:///home/<snip>/vsts-rest-api-specs/specification/git/7.1/git.json:15227:9
fatal   | Error: 1 errors occured -- cannot continue.
git clone https://github.com/MicrosoftDocs/vsts-rest-api-specs.git
autorest --input-file=./vsts-rest-api-specs/specification/git/7.1/git.json --python

Expected behavior Code should be generated

Additional context If the azure devops team maintained an updated python api I wouldn't be doing this:-)

timotheeguerin commented 2 years ago

hey @jabbera not really sure what this spec would even want to generate. JsonPatchDocument is both an object and an array

  "JsonPatchDocument": {
      "description": "The JSON model for JSON Patch Operations",
      "type": "object",
      "allOf": [
        {
          "type": "array",
          "items": {
            "$ref": "#/definitions/JsonPatchOperation"
          }
        }
      ],
      "properties": {}
    },
jabbera commented 2 years ago

@timotheeguerin I guess I'll log a bug with the azure devops team:-) Thanks.

mattmelton commented 1 year ago

I hit this bug today - confirm not fixed.

I was able to work around it by updating the type to "object" (or removing it). Unfortunately I then hit a YAML parsing exception with the Feed API. I suspect the VSTS team aren't dogfooding/using autorest v3. I worked around this with the --legacy flag.