Autorest SDK generation failure for Security Swagger Spec
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.....
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
@chlahav Please look at this issue and modify the security swagger so the SDK could be generated without any issues. Currently the SDKs could not be generated for security swagger.
Created PR #3453 for the swagger file as requested, but it causes a test to fail. please share your insights. worked on it quite a while and didn't succeed to make the auto generation and the test to both pass while describing the objects correctly.
appreciate your help @sarangan12 @fearthecowboy
@sarangan12 @fearthecowboy The PR was merged, please verity that the issue was resolved
@sarangan12 @fearthecowboy the issue was fixed, can you please resolve this issue since I don't have the permissions to do so?
@sarangan12 @fearthecowboy ping :)