question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OpenAPI V3 - Cannot parse OpenAPI v3 definition file with schema containing 'additionalProperties' with boolean value

See original GitHub issue

Hello,

I started to use the latest version of autorest (3.0.6187) which supports OpenApi v3. I have definition file generated from swagger using SwashBuckle library (using .net core application).

I am generating client with autorest using parameter --v3. However autorest returns following error FATAL: AutoRest.Core.Logging.CodeGenerationException: Error parsing swagger file. Error converting value False to type 'AutoRest.Modeler.Model.Schema'. Path 'components.schemas.BrandDto.additionalProperties', line 1, position 1439.

image

It seems that autorest does not support boolean values for additionalProperties as it is supported by OpenApi v3. Anyway if I change the additionalProperties : false to additionalProperties : {} it starts to work.

Here is the sample json used:

{
  "openapi": "3.0.1",
  "info": {
    "title": "Product Global Taxonomy Service API",
    "version": "v1"
  },
  "paths": {
    "/taxonomy/brands": {
      "get": {
        "summary": "Provides taxonomy brands",
        "operationId": "GetTaxonomyBrandsDeprecated",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrandCollection"
                }
              }
            }
          }
        },
        "deprecated": true
      }
    }
  },
  "components": {
    "schemas": {
      "BrandDto": {
        "type": "object",
        "properties": {
          "taxonomyBrandId": {
            "type": "integer",
            "description": "Surrogate Brand Id",
            "format": "int32"
          },
          "name": {
            "type": "string",
            "description": "Brand name",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "BrandCollection": {
        "type": "object",
        "properties": {
          "collection": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BrandDto"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    }
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
cermakpcommented, May 19, 2020

Hi, using --use:@autorest/csharp-v3@3.0.0-dev.20200512.1 or --use:@autorest/csharp-v3@https://github.com/Azure/autorest.csharp/releases/download/3.0.0-dev.20200512.9/autorest-csharp-v3-3.0.0-dev.20200512.9.tgz (as mentioned here) did not help.

However using parameter --version=3.0.6274 helped! Thanks to bernarden

1reaction
timotheeguerincommented, Mar 31, 2021

The only thing that should matter here is the core version (--version=next). Closing as this seems to have been resolved. Will publish to latest in the next few days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenAPI Specification - Version 3.0.3 - Swagger
The OpenAPI Specification defines a standard interface to RESTful APIs which ... Models are defined using the Schema Object, which is an extended...
Read more >
OpenAPI Specification v3.0.3 | Introduction, Definitions, & More
The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.
Read more >
Swagger schema with additionalProperties fails - Stack Overflow
I'd like to post a JSON object within the body of a REST API call. The attribute data of this DATA object contains...
Read more >
Step 5: The components object (OpenAPI tutorial)
The components object is unique from the other objects in the OpenAPI specification. In components, you store re-usable definitions that ...
Read more >
JSON Type Definition RFC 8927 - IETF Datatracker
In this document, a "root schema" is one that is not contained within another schema, i.e., it is "top level". A JTD schema...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found