API Management - Swagger example not showing in APIM but in SwaggerUI

Chu Xu 21 Reputation points
2022-07-11T23:12:40.563+00:00

I am using NewtonSoft for my code with Swashbuckle for swagger documentation examples. When my POST has a JSchema object, in swagger it still displays fine but in APIM it's blank. for example, in the screencopy below, structure is a JSchema, which shows up fine in swagger but then in APIM, the whole request is blank! Can anyone help?

219646-image.png

219638-image.png

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,447 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JananiRamesh-MSFT 29,261 Reputation points
    2022-07-18T17:43:05.013+00:00

    Hi @Chu Xu Thanks for sharing the json file. I had tried validating the json file using swagger validator https://editor.swagger.io/ It initially failed with many errors as given below
    221936-image.png

    when i tried importing in azure portal it failed with below error

    221908-image.png

    I had replaced all the "+" to "." and modified securityschemes as below it was case sensitive issue "scheme: bearer"

    221983-image.png

    "securitySchemes": {
    "Bearer": {
    "type": "http",
    "description": "Specify authorization token without Bearer keyword",
    "scheme": "bearer",
    "bearerFormat": "JWT"
    }
    }
    }

    with all these changes i was able to import the json file successfully in the azure portal. As you mentioned i was not able to see the body in test console. I tried adding the example section as below post which i was able to see the body content in the azure portal

    221909-image.png

    221982-image.png

    so to see the body content by default you need to add the example section in the swagger file please find the modified swagger.json file for schema to create 221870-finalswaggerjson-2.txt

    please let me know incase of further queries, I would be happy to assist you.

    To benefit the community find the right answers, please do mark the post which was helpful by clicking on Accept Answer’ & ‘Up-Vote’.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.