-
Notifications
You must be signed in to change notification settings - Fork 5
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
Export OpenAPI specification for our own VTN #17
Comments
https://crates.io/crates/utoipa/4.2.3 might be helpful |
…ions/codecov/codecov-action-4.5.0 Bump codecov/codecov-action from 4.4.1 to 4.5.0
Hey I've been looking into this issue and I wanted to clarify what the expectations are. Some ways to "export" an openapi spec that come to mind are:
I think all three ways are useful and relatively easy to do (that is what I would default to without any team feedback). I also listed them in order of usefulness/importance, according to my own personal opinion (if for any reason we wanted to only implement a subset). But what does the team think? Also, if someone is already working on this or there are plans by someone to pick it up, please let me know and I'll see if I can be helpful in some other way. |
Hi Ben, thanks a lot for your initiative! We are skeptical about serving the UI though, as we think this would introduce a lot of additional dependencies, and serving a web page feels wrong in an API. The additional value seems limited to us, as web pages like https://editor.swagger.io/ exist and most IDEs can handle the OpenAPI specification as well. The link to I don't know of anyone working on that already. I'm happy to help with any further questions or suggestions, and looking forward to a PR from you! |
Awesome, thanks for the feedback! I'll work on exposing the openapi JSON via a build artifact and endpoint, then. I looked around only briefly and If you're interested to see what a very initial application of the |
Feel free to also open a draft pull request even in an early stage of development, if you like. |
So I think there's three reasonable options for maintaining
Here are my personal, informal thoughts on each option after reading a lot of GitHub issues (more journalism than science :)). Normally I'd avoid manually maintaining a spec in yaml if the option to generate it from code exists. However, in this case it may be appropriate. The api is not a moving target -- it will be similar to the open standard we're implementing, and any changes to the standard will be small, slow, and well-communicated. Of course, any time you have two separate definitions of the same interface (openapi spec and service code), it's an opportunity for bugs -- but perhaps we could mitigate this with a test suite that generates a client from the spec and uses this client to interact with the service, ensuring the spec and code agree. Also, it's always nice to avoid a dependency. The The I don't know which of these three options is most appropriate for this project. I don't have experience using the crates in other projects, so if anyone does please chime in. I'm working on two drafts, one using Let me know if you have any thoughts or if there's anything in particular you think would be good to check is supported by these crates. I should have the draft PRs ready in a few days. |
Nice investigation! I don't have any strong opinion on how exactly to proceed. |
I submitted a couple draft PRs
These drafts are just explorations of each crate, only implementing a couple operations to get a flavor of what it's like to use the libraries. While it was fun to explore, I still don't see a clear winner among the three options mentioned above. I think that maintaining the schema by hand remains a very reasonable choice. The two crates are, in the end, very similar. They both have a macro layer that sits on top of traits, and the traits can be implemented if the macros are giving issues. Personally I prefer the experience of using Interested in your thoughts. Also
do you have a concrete example of what you weren't happy with in the official specification? Perhaps I can weigh in on whether that would affect which crate is a better choice. |
We checked your draft PRs. Thanks for that! One of the problems we identified in the original OpenAPI spec is that fields like Utopia
Aide
If you are interested to start a OpenAPI document, we are happy to see that. I can completely understand if you are not interested, though. If you are motivated to do something else instead, feel free to have a look at the issue board again or poke me if you are in doubt what to do. |
Sounds good. I think I agree that manually maintaining the schema is the most reasonable choice in this case.
I'll take a shot at putting together an OpenAPI document (I'd assume in yaml). It would be nice to see this issue through and it's a good way to get familiar with all the endpoints and data models. But, let me know if at any point the team feels it is best for me to step back and for someone else to address this (such as if it feels more trouble than its worth to communicate all the specific details desired in the final OpenAPI spec via PR comments). |
Sounds good to me. Please go ahead and don't hesitate to ask any questions. |
First question: any thoughts on how to verify that the spec conforms to the VTN implementation? My thought is to use something like |
Sorry I've been out of this repo. I'm doing a career accelerator trying to get into climate tech professionally. Anyway you can generate the swagger and save it as a json file with utopia. Tasks like this are part of the reason I was moving to a cli crate in the workspace. You often need build specific tasks that interact with the workspace. If you do this in clap the code looks like this
Yes there is an unwrap here because this is run as part of a CLI command so a sudden panic is fine in this context. |
@benjaminedwardwebb I'm not quite sure how to do that testing. Maybe not really worth it for now. I never had a great experience with code generators from OpenAPI specifications so far, and I hope the API is not changing too much anyway, so if we get it correct once, it should hopefully stay correct. But if you have the time and motivation to create some (basic) testing using things like progenitor, feel free to do that as well. @KeeganMyers Yes, you are right, |
Sorry I haven't been responsive on this issue recently. I only did a little exploratory work testing some endpoints to confirm the serialization they accepted, and then ended up becoming busy with other things in life. You're of course welcome to remove me from this issue. I may have some time again later December to contribute and if I do I'll see how I can best help then. |
Thanks for letting us know. At the moment, this issue is not of the highest priority to us and we don't know anyone who would like to take over. Therefore, I suggest, we keep you assigned to this issue for now. You are always free to (explicitly) leave it, of course. We communicate in advance if someone else wants to take this issue. |
No description provided.
The text was updated successfully, but these errors were encountered: