-
Notifications
You must be signed in to change notification settings - Fork 95
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
Api rework #1461
Api rework #1461
Conversation
9909ef6
to
a1665f2
Compare
Marking as draft as I've been in contact with the dev working on the openapi documentation within nextcloud. The script isn't even public yet and the current cookbook code might need some cleanup to be generated into a nice looking spec. Some related information can be found here: nextcloud/neon#189 |
I am not sure who you are referring to. Maybe you can ping him/her or post a link to the discussion?
I honestly doubt that this will work for any non-trivial example. At least with the cookbook app, I see no chance. The JSON is generated from a file on the cloud. The data is not generated on the fly. This is also the problem we are facing there: Older versions of the cookbook did work slightly differently. We have to check all these inconsistencies on each invocation. In general, I am a friend of defining an API schema and implementing everything in accordance with that. The cookbook had an implementation already, so this was not possible. The OpenAPI spec was the first step to go toward such a structure. If this API spec is clear, one can write tests to be sure that no code regression is introduced. |
I'd like to second @christianlupus on this. The Openapi spec should be the one source of truth that defines the interface between the back- and frontend. Whenever one is working on the spec document it is then clear that the person needs to be extra cautious. Also AFAIK there are good code generators for creating API clients from the spec already so this is a tested path. Turning it around now and creating a spec from code seems to be dangerous. |
The discussion happened on matrix and the dev in question @provokateurin Maybe @provokateurin could elaborate on their choice as I also haven't gotten it yet. Nevertheless I marked this one as a draft as I'm still checking some stuff with generation and want to get things right first. |
Hi, Regarding @christianlupus concerns about incompatibility: The specs will be versioned of course, so that these things can be handled. It is also possible to define a field as having multiple types like string and int so that multiple versions of the recipe format can be handled at the same time, but that has to be handled on the client side then as well (I guess this is what's already happening?). @seyfeb I also agree with you that there should only be a single source of truth. Cookbook is a bit special because it already has an OpenAPI spec, but as it seems it's not correctly representing the actual API at the moment. Almost all apps (except Cookbook and Maps) don't have any machine readable specification so the code will become the source of truth, since we need one source and the code is almost always the only thing that exists already (e.g. Talk has at least some good docs written down). I know this is very complicated, but I've been working on these things for over a year now and I know many of the problems and solutions. I might make it sound easy, but it's definitely not. Cheers, |
How about another suggestion? The script is not working correctly at the moment and is still under development. Yet, @Leptopoda did write some work on the source manually. No offense, @provokateurin, I cannot imagine this to work on a reproducible manner. This might be my personal inability to imagine the things. I would like to see that in action. Until then, i would rather avoid freezing any API development. If it works, we can still change. Any opinions on that? |
I don't have any objections about this PR or any other work. I was just asked to explain what I'm doing. If it ever comes so far that I try to adapt Cookbook, then I'll just open a PR as usual. I really didn't mean to stop anyone from working on this :/ |
a1665f2
to
8456139
Compare
I am sorry, i had to break this PR apart. Some parts are valid but others are not. It might be better to create smaller chunks that can be understood better. This allows to fix the implementation of there is anything to fix. I am not sure I got all implications of your suggestions, though. Why were you changing/adding the default values e.g.? |
As mentioned above this is still a work in progress especially on how the generator uses the information provided.
The problem is that quite many fields are marked as required in the spec but not really required in the frontend (vue). In the frontend it is enough to provide a name and it will populate the creation date and every other required field. It is mainly for documenting that the Also dart is null safe meaning that if I don't mark a field as 'nullable' I have to provide a value otherwise a runtime error is thrown. Now I could provide a default value in my client or let the generated code do it. I haven't used kotlin but also is nullsafe so this will probably apply there as well. TL;DR
I guess providing a default in the spec is the least breaking as the api will still provide non null responses. As most in this pr is only documenting more of the behavior instead of changing it. It's getting late and I hope my comment still makes sense :) |
fff4aa8
to
7120da4
Compare
Signed-off-by: Nikolas Rimikis <[email protected]>
Signed-off-by: Nikolas Rimikis <[email protected]>
…red flag add default parameters Signed-off-by: Nikolas Rimikis <[email protected]> add operationId to endpoints to name them Signed-off-by: Nikolas Rimikis <[email protected]>
Signed-off-by: Nikolas Rimikis <[email protected]>
7120da4
to
66b2319
Compare
Signed-off-by: Christian Wolf <[email protected]>
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.
Let's get that merged. Looks good now.
implements #1421 and superseds #1445
this covers all Problems I faced when trying to implement a generated API.
If anyone else uses code generation and faces Issues with the now renamed objects (Category, Keyword or Url) many languages (if not all) support
typedef
s so you could use something simple like:although I think a simple
crtl+f
will do the Trick :)The api itself does not cahnge jsut it's documentation does. So there isn't any need to update your client in the first place
The commits are very self explanatory but feel free to ask anything you don't understand.