Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autorest(modelerfour) doesn't handle circular dependencies in additionalProperties #3818

Closed
johanste opened this issue Jan 29, 2021 · 1 comment · Fixed by #3819
Closed
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved.

Comments

@johanste
Copy link
Member

I have a self-referential recursive model definition. Autorest doesn't seem to like it.

$> autorest --input-file=any.json --python      

WARNING: AutoRest has not been tested with Node versions greater than v14.

AutoRest code generation utility [cli version: 3.0.6335; node: v15.4.0, max-memory: 4096 MB]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
NOTE: AutoRest core version selected from configuration: ~3.0.6298.
   Loading AutoRest core      '/Users/johanstenberg/.autorest/@autorest_core@3.0.6369/node_modules/@autorest/core/dist' (3.0.6369)
   Loading AutoRest extension '@autorest/python' (latest->5.6.1)
   Loading AutoRest extension '@autorest/modelerfour' (4.15.442->4.15.442)

...

WARNING (PreCheck/CheckDuplicateSchemas): Checking for duplicate schemas, this could take a (long) while.  Run with --verbose for more detail.
FATAL: Error: RECURSING!  Saw schema Any more than once.
  Error: Plugin modelerfour reported failure.

See below for an example swagger that illustrates the issue...

{
  "swagger": "2.0",
  "info": {
    "title": "Recursive",
    "version": "1.0"
  },
  "produces": [ "application/json" ],
  "consumes": [ "application/json" ],
  "paths": {
    "/resources/{resourceId}": {
      "parameters": [
        {
          "name": "resourceId",
          "in": "path",
          "type": "string",
          "required": true
        }
      ],
      "put": {
        "operationId": "createResource",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/Resource"
            }
          }
          ],
        "responses": {
          "200": {
            "description": "Success, ja!",
            "schema": {
              "$ref": "#/definitions/Resource"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "Any": {
      "additionalProperties": {
        "$ref": "#/definitions/Any"
      }
    },
    "Resource": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "randomProperties": {
          "$ref": "#/definitions/Any"
        }
      }
    } 
  }
}
@johanste johanste added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Jan 29, 2021
@timotheeguerin timotheeguerin changed the title Autorest (modeler 4?) chokes on recursive definitions Autorest(modelerfour) doesn't handle circular dependencies in additionalProperties Jan 29, 2021
@timotheeguerin
Copy link
Member

timotheeguerin commented Jan 29, 2021

Hey @johanste could you confirm the PR fixes the issue for you. There is instruction here to test it locally
#3819 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants