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

Route redirect with poem-openapi #376

Closed
banool opened this issue Aug 29, 2022 · 3 comments
Closed

Route redirect with poem-openapi #376

banool opened this issue Aug 29, 2022 · 3 comments
Labels
question Further information is requested

Comments

@banool
Copy link
Contributor

banool commented Aug 29, 2022

Hey, imagine I have an API defined with the #[derive(Openapi)] macro invocation, and in that API I've got something at the path of /hello. If I wanted an alias for the same path at /hey is there a way to do that? I don't want the alias to appear in the generated spec. Should I just add a new route handler for /hey and add the thing to ignore it from the generated spec? Thanks!

@sunli829
Copy link
Collaborator

What do you think if I add a hidden attribute?

#[OpenApi]
impl MyApi {
    #[oai(path = "/hello", method = "get")]
    fn hello() { }

    #[oai(path = "/hello", method = "get", hidden)]  // hidden attribute to hidden this api in the document
    fn hey() { }
}

@banool
Copy link
Contributor Author

banool commented Aug 30, 2022

I think that'd work pretty well, sounds good to me! Either that or something like this:

#[OpenApi]
impl MyApi {
    #[oai(path = "/hello", method = "get", aliases = ["/hey", "/hi"])]
    fn hello() { }
}

Though the hidden attribute also sounds useful even if we do this other suggestion.

@banool
Copy link
Contributor Author

banool commented Sep 2, 2022

Closing this since hidden works for this :)

@banool banool closed this as completed Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants