OpenAPI: Filter endpoints based on GenerateControllerEndpoints usage #1450
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR filters the listed JSON:API endpoints in the produced swagger.json.
Auto-generated controllers
When using auto-generated controllers, only the endpoints defined on the resource type are shown. For example:
now only displays the corresponding endpoints:
This means that if you're adding a custom implementation of an action method in your partial class, you need to add its flag on
[Resource]
for it to become listed. If you don't, the method is assumed to exist solely to throw an exception when used.This is needed because auto-generated controllers derive from
JsonApiController<,>
, which contains all JSON:API controller action methods. At runtime, an exception is thrown when the endpoint is not accessible.Hand-written controllers
When not using auto-generated controllers, all exposed endpoints are listed. To hide some, derive from
BaseJsonApiController
instead ofJsonApiController
and include only the action methods that should be exposed by adding attributes like[HttpGet]
,[HttpPost]
, etc. There's no way to add action methods that always throw without them being listed.Closes #1052.
QUALITY CHECKLIST