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

feat(webapp): introduce openapi/swagger specification #2425

Merged
merged 3 commits into from
Apr 16, 2024
Merged

Conversation

bonomat
Copy link
Contributor

@bonomat bonomat commented Apr 16, 2024

It is a bit of manual work and boiler plates but once set up it's quite nice.
I've enabled redoc and swagger UI for now but I guess one of them is enough

Note: our authentication seems to be non-standard, and hence, it does not fit to the Swagger authentication. Imho we should fix this to have a fully working swagger client. Supported authentication schemes can be found here

Helps with #2284

bonomat added 2 commits April 16, 2024 09:35
- OpenApi/Swagger can be found under: http://localhost:3001/swagger-ui
- Redoc can be found under: http://localhost:3001/redoc
Copy link
Contributor

@luckysori luckysori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Just some style comments.

webapp/src/api.rs Outdated Show resolved Hide resolved
webapp/src/api.rs Outdated Show resolved Hide resolved
webapp/src/api.rs Outdated Show resolved Hide resolved
Comment on lines -218 to -221
#[serde(with = "bitcoin::amount::serde::as_sat::opt")]
pub coordinator_reserve: Option<Amount>,
#[serde(with = "bitcoin::amount::serde::as_sat::opt")]
pub trader_reserve: Option<Amount>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞 That's a bit annoying.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know :( We could potentially wrap it into another type and then imple ToSchema but I found this was the easiest way.

webapp/src/auth.rs Outdated Show resolved Hide resolved
webapp/src/auth.rs Outdated Show resolved Hide resolved
let router = Router::new()
.route("/", get(index_handler))
.route("/main.dart.js", get(main_dart_handler))
.route("/flutter.js", get(flutter_js))
.route("/index.html", get(index_handler))
.route("/assets/*file", get(static_handler))
.route("/api/version", get(version))
.merge(SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", ApiDoc::openapi()))
.merge(Redoc::with_url("/redoc", ApiDoc::openapi()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓Did you miss /api-docs/ here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, Afaik /swagger-ui needs to find the specification under /api-docs/openapi.json. redocs has its own. We probably only need one of them.

Co-authored-by: Lucas Soriano <lucas@10101.finance>
@bonomat bonomat added this pull request to the merge queue Apr 16, 2024
Merged via the queue into main with commit d034a0e Apr 16, 2024
22 checks passed
@bonomat bonomat deleted the feat/open-api branch April 16, 2024 04:46
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

Successfully merging this pull request may close these issues.

2 participants