autorest
autorest copied to clipboard
Error converting value False to type 'AutoRest.Modeler.Model.Schema'
Since Autorest Core 3.0.6282 was released today, my build is failing to generate c# clients. It was working fine with AutoRest 3.0.6187 and Autorest Core 3.0.6274 just a day ago.
AutoRest code generation utility [cli version: 3.0.6187; node: v12.16.1, max-memory: 8192 gb]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
Network Enabled: true
Starting @autorest/core from /home/vsts/.autorest/@[email protected]
Loading AutoRest core '/home/vsts/.autorest/@[email protected]/node_modules/@autorest/core/dist' (3.0.6274)
Installing AutoRest extension '@microsoft.azure/autorest.csharp' (2.3.82)
Installed AutoRest extension '@microsoft.azure/autorest.csharp' (2.3.82->2.3.82)
Installing AutoRest extension '@microsoft.azure/autorest.modeler' (2.3.55)
Installed AutoRest extension '@microsoft.azure/autorest.modeler' (2.3.55->2.3.55)
The error I'm receiving is:
AutoRest code generation utility [cli version: 3.0.6187; node: v12.16.1, max-memory: 8192 gb]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
Network Enabled: true
Starting @autorest/core from /home/vsts/.autorest/@[email protected]
Loading AutoRest core '/home/vsts/.autorest/@[email protected]/node_modules/@autorest/core/dist' (3.0.6282)
Installing AutoRest extension '@microsoft.azure/autorest.csharp' (2.3.82)
Installed AutoRest extension '@microsoft.azure/autorest.csharp' (2.3.82->2.3.82)
Installing AutoRest extension '@microsoft.azure/autorest.modeler' (2.3.55)
Installed AutoRest extension '@microsoft.azure/autorest.modeler' (2.3.55->2.3.55)
...
DEBUG [11.34 s]: openapi-document/compose - END [0.27 s]
DEBUG [11.35 s]: openapi-document/identity - START inputs = 1
DEBUG [11.35 s]: openapi-document/identity - END [0 s]
DEBUG [11.35 s]: csharp/imodeler1 - START inputs = 1
FATAL: Error parsing swagger file. Error converting value False to type 'AutoRest.Modeler.Model.Schema'. Path 'components.schemas.AdditionalGroupRoleAssignment.additionalProperties', line 1, position 211194.
FATAL: AutoRest.Core.Logging.CodeGenerationException: Error parsing swagger file. Error converting value False to type 'AutoRest.Modeler.Model.Schema'. Path 'components.schemas.AdditionalGroupRoleAssignment.additionalProperties', line 1, position 211194.
at AutoRest.Modeler.SwaggerParser.Parse(String swaggerDocument) in /opt/vsts/work/1/s/src/SwaggerParser.cs:line 52
at AutoRest.Modeler.Program.<ProcessInternal>d__2.MoveNext() in /opt/vsts/work/1/s/src/Program.cs:line 58
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NewPlugin.<Process>d__15.MoveNext()
C:\Users\Bernarden\.autorest\@[email protected]\node_modules\@autorest\core\dist\lib\pipeline\pipeline.js - FAILURE {}
Process() cancelled due to exception : Plugin imodeler1 reported failure. / Error: Plugin imodeler1 reported failure.
at C:\Users\Bernarden\.autorest\@[email protected]\node_modules\@autorest\core\dist\lib\pipeline\plugins\external.js:26:19
at async ScheduleNode (C:\Users\Bernarden\.autorest\@[email protected]\node_modules\@autorest\core\dist\lib\pipeline\pipeline.js:294:33)
Error: Plugin imodeler1 reported failure.
[13.39 s] Shutting Down.
[13.39 s] Exiting.
Looks like the same issue as #3497 and #3439 due to additionalProperties: false
?
Yeah. There are additionalProperties: false
in my swagger definition but as I mentioned above this became an issue only after @autorest/core 3.0.6282 was released. I fixed my immediate issue by adding --version=3.0.6274
to the list of autorest arguments.
tried the switch.. did not work for me I should probably fire separate issue
AutoRest code generation utility [cli version: 3.0.6187; node: v14.2.0, max-memory: 8192 gb] (C) 2018 Microsoft Corporation. https://aka.ms/autorest Loading AutoRest core 'C:\Users\vhaken.autorest@[email protected]\node_modules@autorest\core\dist' (3.0.6274) Loading AutoRest extension '@microsoft.azure/autorest.csharp' (~2.3.79->2.3.84) Loading AutoRest extension '@microsoft.azure/autorest.modeler' (2.3.55->2.3.55) FATAL: The schema's 'Customs.Catalog.Domain.Models.DTO.RetailerPrice-currency' ancestors should have at lease one property FATAL: AutoRest.Core.Logging.CodeGenerationException: The schema's 'Customs.Catalog.Domain.Models.DTO.RetailerPrice-currency' ancestors should have at lease one property at AutoRest.Modeler.SwaggerModeler.BuildCompositeTypes() in /opt/vsts/work/1/s/src/SwaggerModeler.cs:line 361 at AutoRest.Modeler.SwaggerModeler.Build(ServiceDefinition serviceDefinition) in /opt/vsts/work/1/s/src/SwaggerModeler.cs:line 66 at AutoRest.Modeler.Program.<ProcessInternal>d__2.MoveNext() in /opt/vsts/work/1/s/src/Program.cs:line 60 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NewPlugin.<Process>d__15.MoveNext() Error: Plugin imodeler1 reported failure.
the underlying spec piece (type with property tied to enum)
"Customs.Catalog.Domain.Models.Enums.CurrencyIso": {
"enum": [
1,
85
],
"type": "integer",
"description": "Currency Iso Values",
"format": "int32"
},
"Customs.Catalog.Domain.Models.DTO.RetailerPrice": {
"type": "object",
"properties": {
"amount": {
"type": "number",
"description": "Amount",
"format": "double",
"nullable": true
},
"currency": {
"allOf": [
{
"$ref": "#/components/schemas/Customs.Catalog.Domain.Models.Enums.CurrencyIso"
}
],
"description": "Currency",
"nullable": true
}
},
"additionalProperties": false,
"description": "Price"
}
tried the switch.. did not work for me I should probably fire separate issue
From the error message, I think your issue is due to
"currency": {
"allOf": [
{
"$ref": "#/components/schemas/Customs.Catalog.Domain.Models.Enums.CurrencyIso"
}
],
"description": "Currency",
"nullable": true
}
Which is not currently supported by Autorest. See Azure/autorest#2652 and Azure/autorest#3417 for workarounds.
same here:
And i think it has nothing to do with the allOf, because I dont have it in my swagger file.
Also experiencing this issue with 3.0.6282.
3.0.6274 is working just fine.
I am using swagger spec 3.0.1 to generate a python client using autorest. I see varied behavior with different versions. Observation:
1. from 6267 - 6277 - FATAL: System.NullReferenceException: Object reference not set to an instance of an object. is coming
2. from 6280 - 6300 - FATAL: Error parsing swagger file. Error converting value False to type 'AutoRest.Modeler.Model.Schema'. Path 'components.schemas.SomeObject.additionalProperties', line 1, position 88165. is coming
3. from 6302 and above it is creating client but without base_url which we need for implementation.
Can you help us figure out either:
- How to use the clients generated using
azure.core
- How to fix above issues so that somehow we may create client with base_url support.
To add to this my additionalProperties thing got resolved with 3.0.6274 in csharp but fails like above in python.
See also #3524.