-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add OpenAPI metadata to Catalog API #568
base: main
Are you sure you want to change the base?
Conversation
return TypedResults.BadRequest("Id is not valid."); | ||
var problemDetails = problemDetailsFactory.CreateProblemDetails(httpContext, | ||
detail: $"Id is not valid", statusCode: StatusCodes.Status400BadRequest); | ||
httpContext.Response.ContentType = "application/problem+json"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly, the CreateProblemDetails
method fails to set the content-type to "application/problem+json". Even worse is that despite adding the explicit "ProducesResponseType" on this method with the correct content-type, this doesn't make it into the OpenAPI document -- probably because the BadRequest overrides it (incorrectly IMHO).
This PR adds OpenAPI metadata to the Catalog API.
It includes the generated OpenAPI doc, starting from the first commit, so that you can easily see how the doc was changed/improved by the app code changes.
I also included a Spectral ruleset file that checks basic structural correctness and adds rules to verify that all operations have both success and error responses defined and all parameters have descriptions.
The motivation for this work was so we could use this in demos of the OpenAPI document generation feature in upcoming conferences.