Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autorest not generating a model class in c# #198

Open
sashanm opened this issue Oct 16, 2019 · 7 comments
Open

Autorest not generating a model class in c# #198

sashanm opened this issue Oct 16, 2019 · 7 comments
Labels
v2 Version 2 of AutoRest C# generator.

Comments

@sashanm
Copy link

sashanm commented Oct 16, 2019

We have two different API using same model object as explained below,

Case 1:
AddressValidationOutput class has AddressValidationProperties as its property with "x-ms-client-flatten" extension enabled. So as expected AddressValidationProperties is flattened.

Case 2:
ValidationInputResponse has AddressValidationProperties as its knowntype/derivedtype to be used as response. In this case we want AddressValidationProperties class to be generated.

Currently, case 1 is executed first and definition for "AddressValidationProperties " not generated.

"AddressValidationOutput": {
"description": "Output of the address validation api.",
"type": "object",
"properties": {
"properties": {
"$ref": "#/definitions/AddressValidationProperties",
"description": "The address validation properties.",
"readOnly": true,
"x-ms-client-flatten": true
}
}
},
"AddressValidationProperties": {
"description": "The address validation output.",
"required": [
"validationType"
],
"type": "object",
"allOf": [
{
"$ref": "#/definitions/ValidationInputResponse"
}
],
"properties": {
"validationStatus": {
"description": "The address validation status.",
"enum": [
"Valid",
"Invalid",
"Ambiguous"
],
"type": "string",
"readOnly": true,
"x-ms-enum": {
"name": "AddressValidationStatus",
"modelAsExtensible": true,
"values": [
{
"value": "Valid",
"description": "Address provided is valid."
},
{
"value": "Invalid",
"description": "Address provided is invalid or not supported."
},
{
"value": "Ambiguous",
"description": "Address provided is ambiguous, please choose one of the alternate addresses returned."
}
]
}
}
"x-ms-discriminator-value": "ValidateAddress"
},

@MiYanni MiYanni transferred this issue from Azure/autorest Nov 7, 2019
@MiYanni MiYanni added the v2 Version 2 of AutoRest C# generator. label Nov 7, 2019
@abhishek-msft
Copy link

When I generate the client using autorest the models are not getting generated. I don't get any error and the client code is getting generated though.

@abhishek-msft
Copy link

Any update on this?

@mikekistler
Copy link
Member

I think we'll need more context to understand the issue. Which service are you working with and what version of autorest are you using to generate the client? It would be great if you could give the specific command you are using to generate so that we can understand which options are used, etc.

@abhishek-msft
Copy link

Thanks Shivangi for linking the issue above. After adding the switch --generation1-convenience-client the models got created!

@bogdangd
Copy link

Thanks @ShivangiReja and @abmis-mi, I was also stuck finding an answer to this question.
In my case, the --generation1-convenience-client flag only worked in combination with --v3:
autorest --input-file="swagger.json" --csharp --generation1-convenience-client --v3

@ShivangiReja
Copy link
Member

CC: @lirenhe, @chunyu3

@ChuckJonas
Copy link

Where did you find --generation1-convenience-client option? I don't see any references in the docs...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 Version 2 of AutoRest C# generator.
Projects
None yet
Development

No branches or pull requests

7 participants