fix(openapi): add REST API prefix to content-api routes in generated spec#25737
Open
mahmoodhamdi wants to merge 1 commit intostrapi:developfrom
Open
fix(openapi): add REST API prefix to content-api routes in generated spec#25737mahmoodhamdi wants to merge 1 commit intostrapi:developfrom
mahmoodhamdi wants to merge 1 commit intostrapi:developfrom
Conversation
…spec The OpenAPI spec generator reads routes from strapi.apis without applying the REST API prefix (default /api). This causes generated paths like /articles instead of the correct /api/articles. Apply the configured api.rest.prefix to content-api routes in the ApiRoutesProvider, matching how the core content-api service registers routes with the Koa router. Update test fixtures to reflect that routes stored in strapi.apis do not include the prefix, and add tests verifying prefix application and custom prefix support. Fixes strapi#25493
|
@mahmoodhamdi is attempting to deploy a commit to the Strapi Team on Vercel. A member of the Team first needs to authorize it. |
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Adds the configured REST API prefix (
api.rest.prefix, default/api) to content-api routes in the OpenAPI spec generator'sApiRoutesProvider.Why is this change needed?
When running
strapi openapi generate, the generated spec produces paths like/articlesinstead of/api/articles. Since the REST API prefix is applied at the Koa Router level, routes stored instrapi.apisdo not include it. The OpenAPI generator reads these routes directly, so the generated paths are missing the prefix and don't match the actual API endpoints.This follows the same pattern used by the core content-api service when registering routes:
Issue: #25493
Changes
ApiRoutesProvider: Applyapi.rest.prefixto content-api routes (admin routes are left unchanged)strapi.apisdon't include the prefixStrapiMock: Addedconfig.getmethodHow was this tested?
content-apitype routesChecklist
develop