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

Single endpoint with multiple (parameter-dependent) response schemas? #1709

Open
2 of 4 tasks
jeffrey-pinyan-cleandns opened this issue Oct 24, 2024 · 1 comment
Open
2 of 4 tasks

Comments

@jeffrey-pinyan-cleandns

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Detailed Description

I have a rather peculiar use-case, and I'm didn't find anything in the Issues about this already. It feels like it's not a best-practice, so if tsoa doesn't support it, I don't blame you. ;)

I have an API endpoint that needs two rather different response schemas, dependent on what one of the query parameters (a clientId) to the endpoint is. Because the schema is dependent on which clientId you pass the endpoint, I don't want to display both options of schema in the documentation that the user sees, because users with the special-cased clientId don't need to see the generic response schema, and users with the generic response schema don't need to see the special-cased schema for some other clientId.

The API and documentation are currently divided, and I'm able to manipulate the Swagger API specification based on the clientId connected to the user viewing the documentation, so that when their clientId is X, they see the special-cased schema for the endpoint, and when their clientId is not X, they see the generic schema. I do not want to end up creating multiple endpoints for each client that needs a change to the schema; I want to continue using a single endpoint with different response schemas based on the clientId.

In order to unify the API code and docs with tsoa, I'd need a way to replicate this multi-schema endpoint model. Is there a way to do this natively in tsoa, or would I need to add some sort of post-processing step to tsoa's output in order to accomplish this?

Copy link

Hello there jeffrey-pinyan-cleandns 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀

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