-
Notifications
You must be signed in to change notification settings - Fork 204
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
Add ability to exclude routes from OpenAPI docs #984
Conversation
🦋 Changeset detectedLatest commit: f082120 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Hi @rmichalak What use case is this feature? I think it's okay to use just app.get('/books', (c) => c.json([{ title: 'foo' }])) |
Hi @yusukebe,
Will I still have all the type-safety and validation coming from the openapi specification? |
The response can't be typed, but you can use |
Well, but that would mean I need to write more code and use a package which I currently don't use explicitly (although I know it's used behind the scenes). On the other hand, with my change I can use exactly the same patterns as with any other endpoint. Plus it's easier to expose the endpoint dynamically in runtime, e.g. for specific environments: hide: process.env.ENV !== "test" |
I still can't understand why this feature is needed. Is the following not good? const app = new OpenAPIHono()
if (condition) {
app.openapi(
createRoute({
/** */
}),
(c) => c.json([{ title: 'foo' }])
)
} |
@yoshikouki but I do want the endpoint to be available for requests, just hidden from the docs. Let's imagine a new endpoint which we want to test internally, but not announce publicly yet. With your approach, when the I want to achieve something in the middle - deployed but not listed. |
Thank you for the explanation. I fully understand! The code is good, but I've added the comment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Looks good! I'll merge and release a new version. Thank you for your contribution! |
Similar to what is available here: https://github.com/rhinobase/hono-openapi?tab=readme-ov-file#conditionaly-hiding-routes