Autorest - Error generating client class for Squidex Api

I have…

  • [ ] Checked the logs and have provided the logs if I found something suspicious there

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request
  • [ X ] Community Support Request

Current behavior

Expected behavior

Minimal reproduction of the problem

Go to https://domainname/api/content/app/swagger/v1/swagger.json
Download
Use swagger with Autorest :
autorest --v3 --csharp --namespace=Fileshare.API --add-credentials --input-file=“swagger.json” --output-folder=“temp” --debug --verbose

AutoRest code generation utility [cli version: 3.0.6163; node: v12.14.1, max-memory: 8192 gb]
© 2018 Microsoft Corporation.

Output:
Error parsing swagger file. Error converting value False to type ‘AutoRest.Modeler.Model.Schema’. Path ‘components.schemas.UsersDto.additionalProperties’, line 1, position 352280.
FATAL: AutoRest.Core.Logging.CodeGenerationException: Error parsing swagger file. Error converting value False to type ‘AutoRest.Modeler.Model.Schema’. Path ‘components.schemas.UsersDto.additionalProperties’, line 1, position 352280.

Environment

  • [ ] Self hosted with docker
  • [ X ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: [4.1.0.0]

Browser:

  • [ X ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:
Does anyone have any experience while using Autorest and the Squidex API swagger ?
I can’t manage to generate the client classes by any form… Used Nswag also without success, the generation finalizes but the output .cs file has alot of compile errors (base classes defined has abstract for example) and personally I prefer the AutoRest implementation of the clients.

I’m adding another scenario :

Go to the Swagger.io and import the swagger file of Squidex API
Choose Generate Client from the top menu
Choose Csharp

Output is not usable also and don’t even compile (looks like many classes are interpreted like object or Dto’s are missing)

The client library is generated with NSwag and this usually works as expected:

Hi @Sebastian,

thank you for trying to help.
I managed to realize what the problem is when using Autorest to generate client from Squidex/Redoc Swagger file.

Autorest has an interpretation of OpenApi Spec regarding the additionalProperties propertie that when the value is simply false it reads has a schema error.

That said, if anyone is used to generating their clients with Autorest and have problems with Squidex swagger file, you need to do some cleaning to the file before trying to generate:

1 - Remove the first line (Autorest also doesn’t support x-generator…)

“x-generator”: “NSwag v13.1.3.0 (NJsonSchema v10.0.28.0 (Newtonsoft.Json v12.0.0.0))”,

2 - Find and delete all instances of :

“additionalProperties”: false,

Hope this helps someone else!

Cheers

1 Like