MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.28k stars 21.46k forks source link

API Management API Import for OAS 3.1 does not support nullable schema properties #123982

Open shawnmurtagh opened 3 months ago

shawnmurtagh commented 3 months ago

Documentationin question: https://learn.microsoft.com/en-us/azure/api-management/api-management-api-import-restrictions#openapi-specifications

Reproduction Steps

Take the test schema below and try to import it into API Management v2 (note the "TestId" property in the components/schemas section).

Expected

Imports successfully

Actual

Throws syntax error and references previous version of oas validation (3.0.1) It says open api 3.1.0 is supported for import, but when I import a valid 3.1 specification, I receive the following error from APIM:

One or more fields contain incorrect values:

    Parsing error(s): Cannot create a scalar value from this type of node. [#/components/schemas/Test/properties/TestId/type]
    Parsing error(s): The input OpenAPI file is not valid for the OpenAPI specification https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md (schema https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v3.0/schema.yaml).

Issue opened with the OAS specification which clarifies the test OAS below should be allowed: https://github.com/OAI/OpenAPI-Specification/issues/3148#issuecomment-1403719138

The test OAS:

{
    "openapi": "3.1.0",
    "info": {
        "title": "test2232",
        "description": "",
        "version": "1.0"
    },
    "servers": [{
        "url": "https://myapim.azure-api.net/testestestes"
    }],
    "paths": {},
    "components": {
        "schemas":{
            "Test":{
                "type": "object",
                "properties":{
                    "TestId":{
                        "type": ["string", "null"]
                    }
                }
            }
        },
        "securitySchemes": {
            "apiKeyHeader": {
                "type": "apiKey",
                "name": "Ocp-Apim-Subscription-Key",
                "in": "header"
            },
            "apiKeyQuery": {
                "type": "apiKey",
                "name": "subscription-key",
                "in": "query"
            }
        }
    },
    "security": [{
        "apiKeyHeader": []
    }, {
        "apiKeyQuery": []
    }]
}

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

PesalaPavan commented 3 months ago

@shawnmurtagh Thanks for your feedback! We will investigate and update as appropriate.

Naveenommi-MSFT commented 2 months ago

@shawnmurtagh Thank you for bringing this to our attention. I've delegated this to content author @dlepow, who will review it and offer their insightful opinions.