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

fix(openapi): multi-level group route .openapi() parsing #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mrsafalpiya
Copy link
Contributor

Consider the following contents of the start/routes.ts file:

router.group(() => {
  router.group(() => {
    router.get("/foo")
      .openapi({  // OpenAPI options of actual route (3rd level)
        responses: {
          "403": {
            ...
          },
        },
      });
  }).openapi({  // OpenAPI options of 2nd level group
    responses: {
      "402": {
        ...
      },
    },
  });
}).openapi({  // OpenAPI options of 1st level group
  responses: {
    "401": {
      ...
    },
  },
});

For readability, the above routes can be viewed in POV of HTML tags as:

<Group openapi={{ responses: { '401': ... } }}>
     <Group openapi={{ responses: { '402': ... } }}>
         <Route get="/foo" openapi={{ responses: { '403': ... } }} />
     </Group>
 </Group>

Previously, the openapi options of the 1st level group was ignored i.e. 401 response. So only 402 and 403 responses were parsed.

This PR fixes the above bug for any group route level by using recursive function to parse group routes.

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.

1 participant