Azure / api-management-developer-portal

Developer portal provided by the Azure API Management service.
MIT License
478 stars 306 forks source link

Missing schemas that are not directly referenced (polymorphic) #2433

Closed hagagps closed 3 months ago

hagagps commented 3 months ago

Bug description

We use polymorphic responses with an abstract class and discriminator property $type where value is name of implementation class. We automatically include all implementation schemas of the abstract class in our swagger doc. Uploading and downloading the doc from APIM shows all the schemas, however the portal neither shows the schemas nor the properties/descriptions that come along with them.

AbstractResponse class image

ImplementationResponse class image

Reproduction steps

  1. Create swagger document with AbstractResponse and ImplementationResponse shown above
  2. Upload doc to APIM
  3. Only AbstractResponse schema is shown in portal

Expected behavior

All schemas in swagger doc are shown, along with properties and descriptions.

Is your portal managed or self-hosted?

Managed

ygrik commented 3 months ago

Hello @hagagps

Could you please provide the swagger file example and screenshots from your developer portal and your expected result.

hagagps commented 3 months ago
{
    "openapi": "3.0.1",
    "info": {
        "title": "API",
        "description": "Find ...",
        "version": "2.0"
    },
    "servers": [
        {
            "url": ""
        }
    ],
    "paths": {
        "/": {
            "get": {
                "summary": "Find",
                "description": "#### Find ...",
                "operationId": "Find",
                "parameters": [
                    {
                        "name": "tag",
                        "in": "query",
                        "description": "Tag",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "pageNumber",
                        "in": "query",
                        "description": "Format - int32.",
                        "schema": {
                            "type": "integer",
                            "format": "int32"
                        }
                    },
                    {
                        "name": "pageSize",
                        "in": "query",
                        "description": "Format - int32.",
                        "schema": {
                            "type": "integer",
                            "format": "int32"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "List",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ResponseArray"
                                },
                                "example": [
                                    {
                                        "$type": "string",
                                        "id": "string"
                                    }
                                ]
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "AbstractResponse": {
                "type": "object",
                "properties": {
                    "$type": {
                        "type": "string"
                    },
                    "id": {
                        "type": "string"
                    }
                },
                "discriminator": {
                    "propertyName": "$type"
                }
            },
            "ImplementationResponse1": {
                "type": "object",
                "allOf": [
                    {
                        "$ref": "#/components/schemas/AbstractResponse"
                    }
                ],
                "properties": {
                    "type": {
                        "type": "string"
                    }
                }
            },
            "ImplementationResponse2": {
                "type": "object",
                "allOf": [
                    {
                        "$ref": "#/components/schemas/AbstractResponse"
                    }
                ],
                "properties": {
                    "label": {
                        "type": "string"
                    }
                }
            },
            "ResponseArray": {
                "type": "array",
                "items": {
                    "$ref": "#/components/schemas/AbstractResponse"
                }
            }
        }
    }
}

The portal only shows ResponseArray and AbstractResponse.

image

image

Would expect to see both implementation schemas.

image

It could even call out abstract to associate them.

image

sthirthala commented 3 months ago

Please log managed portal issues to Azure support team using Support + Help link in Azure portal and select Problem Type = Developer portal.