autorest: An in body parameter with discriminator does not show up in the method signature

I have an API with the following parameter in the swagger spec -

{
        "name": "resultQuery",
        "in": "body",
        "description": "Query to retrieve results based on the query type.",
        "required": true,
        "schema": {
          "$ref": "#/definitions/ResultQuery"
}

This is the schema for the object -

{
	"ResultQuery": {
		"description": "Query for a particular result.",
		"required": ["queryType"],
		"type": "object",
		"properties": {
			"queryType": {
				"description": "Query type which specifies which result needs to be queried.",
				"enum": ["Enum1", "Enum2"],
				"type": "string",
				"x-ms-enum": {
					"name": "ResultQueryType",
					"modelAsString": false
				}
			}
		},
		"discriminator": "queryType"
	}
}

When I generate the client DLL for this spec, the method signature does not have the ResultQuery. However, It works when I remove the discriminator attribute from the schema of “ResultQuery” but then the method does not support polymorphism.

Any workarounds for this?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

Yes, #1726 should have fixed it. (Fixed it in the test I created 😃 )