How can I use a schema in API management developer portal?

Josefine Karlsson 26 Reputation points
2022-08-31T15:50:32.967+00:00

Hi!
I am experimenting with adding a schema to APIM and using the validation policy in an API to validate against that schema, and the actual validation seems to be working just fine. But when looking at the API in the developer portal, there is no example request etc that I can see. My question: in order to get a neat sample and information about the schema in the developer portal, can I somehow reference the imported schema under representation (or as a definition)? Want the validation and the information to be based on the same info and not have to update twice.

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

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,141 Reputation points
    2022-09-08T13:32:56.027+00:00

    @Josefine Karlsson Thank you for your response. You can import API with schema definition in the APIM instance and add multiple examples as per OpenAPI specification. Both examples and schemas for XML payloads are displayed in the developer portal (refer Added basic XSD schema support).

    Here is the sample that I created:

    238697-image.png

    The schema used in the validation of policy is for runtime validation and unfortunately, we cannot reference it in the definition (has to be specified manually or automatically generated during the import like I tested above). However, by default, validate-content policy does use schema attached to API. Which means you can add validation content policy without specifying schema id that would pick default schema in the definition (refer sample request and response)

    239112-image.png

    Al

    Sample
    Request:
    239168-image.png

    Response:
    239262-image.png

    This is great feedback and would be nice to have such feature. I passed on the feedback to our product team internally. Also, I would recommend you posting it in https://aka.ms/apimwish so that others can upvote it too. I hope this answers your question and feel free to add if you have any questions. I would be happy to assist you.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community.


0 additional answers

Sort by: Most helpful