mia-platform / mia-platform/lc39

The prefix with or without trailing slash is applied erroneously to the simple API /

Open
#380 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
20
Forks
2
PR merge metrics
No merged PRs in 30d

Description

## The description of the bug or the rationale of your proposal

If it is configured a custom prefix and there is a API with path '/', the resulting OAS documentation is wrong.

## A snippet of code for replicating the issue or showing the proposal usage if applicable

Using the prefix `/prefix/` and registering the `GET /` the OAS is the following (see this test https://github.com/mia-platform/lc39/blob/5aa476965ce8a739d69e334de092fc9193fb71f1/tests/documentation-routes.test.js#L56):
![Schermata del 2024-08-06 11-58-07](https://github.com/user-attachments/assets/128bc7d7-7c7f-43a7-b700-78b86349e9bc)

Using the prefix `/prefix` and registering the `GET /` the OAS is the following (see this test https://github.com/mia-platform/lc39/blob/5aa476965ce8a739d69e334de092fc9193fb71f1/tests/documentation-routes.test.js#L82):
![Schermata del 2024-08-06 11-58-22](https://github.com/user-attachments/assets/9c4a3b8a-b3a2-4fed-a22f-209083f94006)

Note
Consider that in these tests fastify use the default settings:
- ignoreTrailingSlash: false (https://fastify.dev/docs/latest/Reference/Server/#ignoretrailingslash)
- prefixTrailingSlash: 'both' (https://fastify.dev/docs/latest/Reference/Routes/#routes-options)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the two cases in tests/documentation-routes.test.js, linked around lines 56 and 82, and compare the generated OAS paths for prefixes with and without a trailing slash. Read the route documentation generation entry point used by these tests, keeping Fastify's ignoreTrailingSlash and prefixTrailingSlash defaults in mind. Done means both prefix forms produce the correct path for a registered GET / route.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.