Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

mikekistler
Copy link

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.

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";
Copy link
Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants