-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
Upgrade Swagger data to OpenAPI 3.1 #1310
Conversation
I'm going to mark this as "ready for review" to gather some feedback. It's likely to get overlooked while it's in draft. |
@zecakeh thank you so much for picking this up - there is a lot of great work here and I am very excited to see it land! I've made a few comments in reply to your questions. Generally, I'd love it if we could find ways to pull out bits of this PR to reduce the size of it. For example:
Another question: How much manual editing did you do? Should we aim to script the changes? It might be easier to review a set of conversion scripts than 167 manually-edited files! |
Thanks for the feedback.
Done in #1331.
Sure, I'll look into it.
I think I did more manual editing than necessary, mostly because I didn't know what I was getting into, and what a valid result would look like. I'll look into writing scripts to automate most (or all) of it. |
I split the different steps needed for conversion, between automatic and manual steps. I also removed the changes that are not strictly necessary. With these commits:
I found out another small thing that could reduce the diff if done in a separate PR: switching the definitions and tools to use |
I tried with another validator (namely Redocly CLI) and it complained about a few things. I trust these changes because most of them are required by swagger-parser when declaring the files as OpenAPI 3.0.0, but it stops complaining for some reason when the version is OpenAPI 3.1.0. They also make sense. Redocly CLI also complains about |
a0bc100
to
399755c
Compare
Ok. As I understand it, there are only a couple of places where this is a problem? If so, let's fix it by just copying the complete content into the right place instead of using Likewise, would you be able to open a separate PR for getting rid of |
Done in #1349.
Done in #1350. |
@zecakeh it's gone a bit quiet here, so I just wanted to say I'm still very excited about seeing this land. I'm trying to push through MSC3938 so we can fix the |
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.
Starting slow: please see some comments from reviewing application-service/
, meanwhile I'm in for CS API (but that will likely be my Christmas reading).
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.
A few more from the first part of client-server/
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.
Okay, client-server/
done.
I realise that the whole body will probably have to be re-converted from the most recent API definitions, so applying those suggestions now would not be prudent - but at least those can be used to apply changes after (or even before, like adding missing http
schemes).
# $ref: "definitions/one_time_keys.yaml" | ||
# XXX: We can't define an actual object here, so we have to hope | ||
# that people will look at the swagger source or can figure it out | ||
# from the other endpoints/example. |
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.
AFAIR, this can be reconsidered now that we have OpenAPI v3 expressive powers - namely, definitions/one_time_keys.yaml
is written with OpenAPI v3 in mind.
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.
The rest except server-server
is covered. Got a couple of ideas after reviewing the scripts - please find below.
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.
The last piece, server-server/
completed. This one has been more problematic - aside from things I could debug (see the comments), most concerning is that the conversion has apparently lost a few examples. I guess it might be because of some weird example
/examples
confusion or the wrong level of nesting but didn't dig into this, honestly.
What I would suggest after figuring out what to do on each item from the laundry lists above:
|
Thanks for taking the time to review everything, I'll try to open PRs for those in the next days. |
So we should be good to re-apply the upgrade after #1454 is merged and we agree on the correct fix for |
Those PRs are all merged - we should be good to go? |
Upgrade re-done on main. I have added back all comments and examples that were gone. I checked that it passed two OpenAPI validators (swagger-parser and redocly-cli) and that the generated spec has no unwanted changes. Before merging this we probably want to revert the commit adding the conversion scripts, but I thought it would be better if they were part of the branch history. |
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.
Sorry for the delayed review. Things are mostly in order now, save for one place with the user agent string sliced into parts in some weird (and actually not correct) way, and examples being kind-of-but-not-quite JSON now. I suggest we go forward with the currently formatted examples, but please address the first comment. Then (after yet another rebase... sorry for that) it should be good enough for merging.
Should I wait until #1495 is merged to rebase, to avoid a conflict? |
It has been merged, so should be safe to rebase. 😉 |
Signed-off-by: Kévin Commaille <[email protected]>
Signed-off-by: Kévin Commaille <[email protected]>
Signed-off-by: Kévin Commaille <[email protected]>
Signed-off-by: Kévin Commaille <[email protected]>
Signed-off-by: Kévin Commaille <[email protected]>
Signed-off-by: Kévin Commaille <[email protected]>
This reverts commit 667c39f.
Rebased on latest main. I was unhappy to leave the examples as is so I wrote a dirty little JS script that converts them back to JSON. Hopefully that reduces the diff. |
Thanks for your patience, again. I think it is as good as it can be for now. The remaining comments can be addressed later. @matrix-org/spec-core-team, I guess it's quite a good moment to merge this, while Matrix v1.8 is still kind of away and there's still time to iron parts that still stick out? |
So I should rebase one last time to resolve the conflicts so it can be merged? |
yes please - either rebase, or better yet, just merge main into your branch and fix up the conflicts by hand, so the changes since @KitsuneRal's review are easy to see. Once you've done so I will press the merge button. |
I'm not sure merging will work here because the PR is effectively generated every time. If there's any new endpoint (and I think there was some over this month) it has to be converted by the script. Up to the hero to decide though. |
I improved the script to be able to run it on a single file at a time so I was able to make a merge commit. Once again I checked that they pass the validation and that the generated Matrix spec doesn't have any changes. |
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.
🎉
Thank you so so much to @zecakeh for all your hard work on this, and to @KitsuneRal for reviewing it. It's fantastic to finally have this landed |
This is still a rough draft.
What was done to get here:
scripts/validator.js
on the folders indata/api
and fixed any issue that was reported.servers
. I edited them to split the URLs into variables so we can access thebasePath
easily for the other tools.$ref
).scripts/dump-swagger.py
to adapt to the changes in the data and generate valid OpenAPI 3.1 data.scripts/swagger-preview.html
to allow to preview the generated API with RapiDoc, and to make sure that it works. Also updated the README to replace instructions for previewing with Swagger UI (which is not compatible with OpenAPI 3.1).What's left to do:
data/api/server-server
:keys_query.yaml
andkeys_server.yaml
: thekeyId
property in the path cannot berequired: false
, in the OpenAPI 3.1 spec, all properties in path must berequired: true
.invites-v1.yaml
andinvites-v2.yaml
: the validator complains that it cannot resolve the reference in the example of the 200 response. It's not true because the same reference is used at another place in the file without any issue, so there must be something wrong with the syntax around the$ref
.I'll open discussions on the code for feedback for the remaining tasks.
Closes #331.
Signed-off-by: Kévin Commaille [email protected]
Preview: https://pr1310--matrix-spec-previews.netlify.app