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

Allow to generate the openapi from the axum router without serving it #6

Open
slinkydeveloper opened this issue Apr 25, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@slinkydeveloper
Copy link
Contributor

Hi, I would like to be able to extract the specification generated by Router::route_openapi_specification without serving the contract, how can I do it? Could we split route_openapi_specification in two steps?

@Flowneee
Copy link
Owner

Flowneee commented Apr 29, 2023

Hi. Currently you can do the same as route_openapi_specification https://github.com/Flowneee/okapi-operation/blob/master/okapi-operation/src/axum_integration/router.rs#L327, since necessary methods are public:

let mut routes = self.routes_operations().openapi_operation_generators();
let spec = openapi_builder
    .add_operations(routes.into_iter().map(|((x, y), z)| (x, y, z)))?   // don't even ask :)
    .generate_spec()?;

Could we split route_openapi_specification in two steps?

Maybe instead add method which will add routes from Router to provided OpenApiBuilder? Something like Router::add_routes(&mut self, builder: &mut OpenaApiBuilder.

I am currently trying to rewrite entire axum integration, if OpenApiBuilder stays I will definitely add this feature.

If someone willing, it could be added to current version

@Flowneee Flowneee added the enhancement New feature or request label Apr 29, 2023
@slinkydeveloper
Copy link
Contributor Author

@Flowneee any update on your refactoring of the axum integration? It would be nice to have this feature somewhat soon :)

@Flowneee
Copy link
Owner

Flowneee commented Dec 3, 2023

I published a 0.3.0-rc1 version, which include

  • refactoring
  • update to axum 0.7

Check it out, feedback would be appreciated. I'm gonna keep this issue open for now until it is not released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants