api-management-developer-portal
api-management-developer-portal copied to clipboard
Samples for response definitions with Problem JSON content type failing to show in developer portal
Bug description
In the event a response definition for an endpoint is specified to have content type of application/problem+json
(per RFC 7807), the sample for that response definition will not display properly on the developer portal page for that endpoint, instead displaying the generic JavaScript [object Object]
. If the content type is changed to application/json
for the endpoint response, the sample will display as normal.
This bug is a recent addition, as we've been using application/problem+json
for a while and haven't had any problems with it until recently. Unfortunately, we don't know the exact time this problem started occurring.
Reproduction steps
- Under an APIM instance in Azure Portal, go to 'APIs'.
- Select an API from the left side bar of the resulting pane.
- Select 'Definitions'.
- Select '+ Add definition'.
- Give the definition the name
RFC7807Response
. - Paste the definition provided below into the 'Payload' field.
- Select 'Create definition'.
- Select 'Operations'.
- Select '+ Add operation'.
- Give the operation any name, verb, and URL.
- Select 'Responses'.
- Select '+ Add response'.
- Select status code 400.
- Specify 'Content Type' as
application/problem+json
. - Paste the sample sample provided below into the 'Sample' field.
- Select
RFC7807Response
for the 'Definition' field. - Select 'Save'.
- In a new tab, navigate to the API Details page for the API in the APIM instance's developer portal.
- Select the new API endpoint.
- Scroll down to the table view for the 400 response definition.
Definition:
{
"required": [
"Status",
"Title"
],
"type": "object",
"properties": {
"Status": {
"type": "integer",
"description": "HTTP status code returned"
},
"Title": {
"type": "string",
"description": "Primary message for the error"
},
"Detail": {
"type": "string",
"description": "Secondary message for the error, if applicable"
},
"Errors": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
},
"description": "(string, string[]) dictionary of parameter-specific problems for a semantic error, if applicable"
}
}
}
Sample:
{"Status":400,"Title":"The provided parameters failed to validate.","Errors":{"operation":["is badly formatted in the body."]}}
Expected behavior
The following is provided under 'Example' for the 400 response definition:
{
"Status": 400,
"Title": "The provided parameters failed to validate.",
"Errors": {
"operation": ["is badly formatted in the body."]
}
}
Actual behavior
The following is provided under 'Example' for the 400 response definition:
[object Object]
Is your portal managed or self-hosted?
Managed
API Management service name
qa-resku-rga-apim
Offending definition is RFC7807Response
, which is used on all endpoints as the response definition for 400, 401, 422, and 500 responses
400 response on endpoint 'Close RA' was updated to application/json
to verify the problem was specific to application/problem+json
Custom domain for portal: https://qa-rga-docs.reskureturns.com/
Environment
- Operating system: Windows 10 (latest)
- Browser: Google Chrome, Microsoft Edge
- Version: 95, 95 (respectively)
@sykesjd, thank you for opening this issue. We will triage it within the next few business days.
@sykesjd, thank you for reporting the bug.