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.

Autorest SDK generation failure for Security Swagger Spec

See original GitHub issue

The following autorest SDK generation command fails:

autorest --package-name=azure_mgmt_security --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/555cfa70276c824ca18c1e41072e7c0562cbadc3/specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/security.json --namespace=Azure::Security::Mgmt::V2015_06_01_preview --title=SecurityManagementClient --package-version=0.16.0 --output-folder=/Users/saranganrajamanickam/Projects/azure-sdk-for-ruby/management/azure_mgmt_security/lib/ --ruby --azure-arm
..........
..........
FATAL: System.InvalidOperationException: Found incompatible property types ,  for property 'properties' in schema inheritance chain 
   at AutoRest.Modeler.SchemaResolver.ExpandAllOf(Schema schema) in C:\Users\ci\AppData\Local\Temp\PUBLISHv6236\20_20171009T223650\autorest.modeler\src\SchemaResolver.cs:line 157
   at AutoRest.Modeler.SchemaResolver.Unwrap(Schema schema) in C:\Users\ci\AppData\Local\Temp\PUBLISHv6236\20_20171009T223650\autorest.modeler\src\SchemaResolver.cs:line 75
   at AutoRest.Modeler.SchemaBuilder.BuildServiceType(String serviceTypeName) in C:\Users\ci\AppData\Local\Temp\PUBLISHv6236\20_20171009T223650\autorest.modeler\src\SchemaBuilder.cs:line 35
   at AutoRest.Modeler.SwaggerModeler.BuildCompositeTypes() in C:\Users\ci\AppData\Local\Temp\PUBLISHv6236\20_20171009T223650\autorest.modeler\src\SwaggerModeler.cs:line 300
   at AutoRest.Modeler.SwaggerModeler.Build(ServiceDefinition serviceDefinition) in C:\Users\ci\AppData\Local\Temp\PUBLISHv6236\20_20171009T223650\autorest.modeler\src\SwaggerModeler.cs:line 69
   at AutoRest.Modeler.Program.<ProcessInternal>d__2.MoveNext() in C:\Users\ci\AppData\Local\Temp\PUBLISHv6236\20_20171009T223650\autorest.modeler\src\Program.cs:line 53
--- 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: ruby/modeler - FAILED
FATAL: Error: Plugin modeler reported failure.
Process() cancelled due to exception : Plugin modeler reported failure.

Note This happens for the generation of ALL SDKs and not specific to Ruby SDK. The error happens here in the following condition:

.......
.......
if (!SchemaTypesAreEquivalent(parentProperty, unwrappedProperty))
{
     throw new InvalidOperationException(
             string.Format(CultureInfo.InvariantCulture,
             Properties.Resources.IncompatibleTypesInBaseSchema, propertyName,
             parentProperty.Type,
             unwrappedProperty.Type, schema.Title));
}
.......
.......

In the above condition, the code compares the models ExternalSecuritySolution and CefSolutionProperties. I have checked (both manually and through oav tool). These models are not similar or related. So, I am not sure about the root cause of this error.

Note that if the above condition is removed, I am able to generate the SDK successfully. But, I am not sure why this condition was added in the first place and the reason behind it. So, I am raising this issue with the autorest team.

Also, please note that this specific security service has been requested by our customer - Chef. So, it would be greatly appreciated if this issue is resolved in a timely manner. Thanks

@fearthecowboy @veronicagg @salameer FYI…

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
fearthecowboycommented, Jun 20, 2018

Well, it 's trying to determine if two schemas are the same or not, because when it’s merging definitions, it’s not a hyper-smart recursive merge algorithm.

It’s finding that ExternalSecuritySolution has a property called properties. CefExternalSecuritySolution does an allOf with the ExternalSecuritySolution model. CefExternalSecuritySolution is also declaring a property called properties which is of type CefSolutionProperties

The AutoRest modeler uses inheritance to represent allOf, and this swagger is trying to have a child with a redefinition of the properties property.

There is no way to merge the two child definitions …ESPECIALLY with a polymorphic discriminator in the way.

abstractly, it’s trying to do this:

class ExternalSecuritySolution {

  object properties;
}

class CefExternalSecuritySolution : ExternalSecuritySolution  {
  CefSolutionProperties properties; // *** it's trying to redeclare 'properties'  
}

Take the properties property definition out of the base class, and have a separate model that all the child class properties model types can do an allOf with.

G

0reactions
chlahavcommented, Oct 16, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

AutoRest and OpenAPI: The backbone of Azure SDK
AutoRest is a tool that provides a code generation framework for converting OpenAPI 2.0 and 3.0 specifications into client libraries for the ...
Read more >
Adding REST API client failed - Visual Studio Feedback
[Info]Generating client model from swagger model. [Fatal]Invalid swagger 2.0 specification. Missing version property. Exception: There was an error during code ...
Read more >
AutoRest generates the client ctor as internal + ignores the ...
Looking into the AutoRest source code, it will only create public constructors if the security schema in the OpenAPI spec is set to...
Read more >
OpenAPI.Tools
Serves Swagger UI and OpenAPI 3 spec out of the box. Generate code to interact with other OpenAPI-compliant APIs, or generate new API...
Read more >
Java Integration | Swagger Open Source
Export jooby apps to Swagger Spec 2.0. restlet-framework, Restlet Framework extension that supports auto-generation of Swagger 2.0 from Restlet API and JAX-API ......
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