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

Not able to set the summary of routes inside resource and shallowResource #29

Open
alessandrojean opened this issue Dec 21, 2024 · 0 comments

Comments

@alessandrojean
Copy link

alessandrojean commented Dec 21, 2024

Hi!

I was trying to use the @tuyau/openapi package to create the API definition of my application, and although I am able to properly use the .openapi function in normal independent routes, I am facing some issues while using it in routes defined with .resource and .shallowResource.

It seems the parameters passed to actions are not being used during the generation, but the global ones are working fine.

Some basic reproduction in routes.ts:

router
  .group(() => {
    router
      .resource('users', UsersController)
      .params({ users: 'user' })
      .apiOnly()
      .where('user', { match: /^(@me|\d+)$/ })
      .use(['update', 'show', 'index', 'destroy'], middleware.auth({ guards: ['api'] }))
      .openapi({
        global: { tags: ['Users'] },
        actions: {
          index: { summary: 'List users' },
        },
      })

    router
      .shallowResource('users.libraries', LibrariesController)
      .params({ users: 'user' })
      .apiOnly()
      .where('id', router.matchers.number())
      .where('user', { match: /^(@me|\d+)$/ })
      .use('*', middleware.auth({ guards: ['api'] }))
      .openapi({
        global: { tags: ['Libraries'] },
        actions: {
          index: { summary: 'List user libraries' },
        },
      })
  })
  .prefix('/api/v1')

This code is generating the definition like this:

image

The autocompletion seems to be working fine, so maybe there's some bug which is causing the action of each inner route of the resource to not be read during the generation.

Thanks for your time and for the awesome library, btw!

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

No branches or pull requests

1 participant