autorest: KeyNotFoundException: The given key was not present in the dictionary.
Hi Guys,
Today we’ve got the following exception:
AutoRest code generation utility [version: 2.0.4413; node: v12.14.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
Loading AutoRest core 'C:\Users\yahor_si\.autorest\@microsoft.azure_autorest-core@2.0.4413\node_modules\@microsoft.azure\autorest-core\dist' (2.0.4413)
Loading AutoRest extension '@microsoft.azure/autorest.typescript' (~4.2.0->4.2.4)
Loading AutoRest extension '@microsoft.azure/autorest.modeler' (2.3.51->2.3.51)
FATAL: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at AutoRest.Modeler.SwaggerModeler.Build(ServiceDefinition serviceDefinition) in c:\publish\autorest.modeler\src\SwaggerModeler.cs:line 142
at AutoRest.Modeler.Program.<ProcessInternal>d__2.MoveNext() in c:\publish\autorest.modeler\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()
FATAL: typescript/imodeler1 - FAILED
FATAL: Error: Plugin imodeler1 reported failure.
Process() cancelled due to exception : Plugin imodeler1 reported failure.
Error: Plugin imodeler1 reported failure.
The command line we use looks like this
$SwaggerSpec = "src/app/Api/TeamGateApiSwaggerSpec.json"
$OutputFolder = "."
$SecureSourceFolder = "src/app/Api/Secure"
$UnsecureSourceFolder = "src/app/Api/Unsecure"
# Generate Client with Auth support
autorest --add-credentials --source-code-folder-path=${SecureSourceFolder} --override-client-name=TeamGateApiSecured --input-file=${SwaggerSpec} --typescript --output-folder=${OutputFolder}
And swagger spec is attached in the zip TeamGateApiSwaggerSpec.zip
Any ideas on how we could fix it are really welcome! Thanks!
PS: And of course thank you for the cool tool! PPS: Sorry if that is a wrong repo for this issue
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (12 by maintainers)
If you use NSwag, you can do something like:
SimplifyAllOfPropertiesProcessor.cs
Startup.cs
@fearthecowboy Here’s swashbuckle author explains rationale behind this (I resolved my own issue using advice from this thread, just wanted to add this as a reference).
This might be terrible swagger, but it seem to be valid one?
This is similar to what is generated by Swashbuckle 5, so to change it to something more autorest-friendly I would have to manually override schema generation for all classes with enum properties.