-
-
Notifications
You must be signed in to change notification settings - Fork 359
Add swagger json #46
Add swagger json #46
Conversation
For the uninitiated, you can upload the |
@nik-john Awesome. I've heard of Swagger but we haven't used it in a project before. Would anyone who's familiar with Swagger be interested in helping QA this PR? |
@QuincyLarson I've not got a ton of experience on it either but if you want to see it in action, you can upload the |
are we going to use the swagger doc to create server and client stubs? I see that as a way to unblock front end devs and also write test cases :) |
My suggestion would also to have a linter in place early for swagger, I have seen swagger docs get messy very quickly, I like using speccy for this ~ https://github.com/wework/speccy |
@koundinya @email2vimalraj Would you like to contribute to this PR and review it? @email2vimalraj - I saw your comment on another PR about the open API spec, therefore tagging you |
@nik-john: Super fast man. I would definitely help reviewing it. I’m currently at work and will take a look tonight. |
Speccy seems to be very interesting - I've used JSON Schemas for this a while ago, but this is something we should do once the app is in good shape |
OpenApi supports yaml too, the linting won’t be an issue in that case |
"but this is something we should do once the app is in good shape" agree! 👍 |
The pr looks interesting, definitely gonna review it later tonight utc+7 |
Nitpick here: this is using v2.0 of the spec. OpenAPI Spec 3 has been out for awhile, to the point that swagger-ui supports it just fine for visualizing, and for an API as simple as this one should be we shouldn't end up with too many rough edges. I recently built an OAS3-documented API, albeit via (quite similar to the end output format and manually written) annotations that compiled to JSON rather than building the doc directly by hand, in answer to the inevitable questions y'all should be asking me: "why do you have an opinion on this and why do we care about your opinion" ;) |
With the above said, if this spec gets rewritten as OAS3.0, I'd be happy to review it beyond a cursory glance via the Swagger editor. |
@iansltx I haven't particularly worked with Swagger/OAS3 recently, but I have converted the JSON to OAS3. Do take a look sometime |
Thanks! Calling it a night shortly, but if this hasn't moved out from under my by the time I'm back online again I'll absolutely look through. |
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.
Looks good here. Simple find/replace.
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.
@iansltx Asked me to take a look at this due to some time constraints. Everything looks pretty solid, but I do have some suggested changes looking everything over.
I do agree with the comments about adding some OpenAPI linting in place either using Speccy or Stoplight.io's Spectral.
api/swagger.json
Outdated
"externalDocs": { | ||
"description": "Find out more about Swagger", | ||
"url": "http://swagger.io" | ||
}, |
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.
Are there chapter.io docs that this externalDocs
section could refer to instead?
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.
We don't have one as yet - this was just meant as placeholder
@nik-john Aren't we using |
The consensus was that we aren't using GraphQL (unless something changed that I was unaware about) |
Thanks, @nik-john for updating me. Will review it |
@hskrasek About this
Would you be open to chipping in with this implementation? I'm afraid I don't have a lot of experience with either of those |
Also, the YAML file would be easier to digest and read. Would love to know about your opinion
I guess, just install the tool locally and try to run the tool across PS: Fixing one issue, I found |
Co-Authored-By: Franco Correa <[email protected]>
Co-Authored-By: Franco Correa <[email protected]>
Co-Authored-By: Franco Correa <[email protected]>
Co-Authored-By: Franco Correa <[email protected]>
@koundinya, were you thinking of using the codegen CLI tool (provided by swagger) to achieve this? I've found in the past that it's picky about the files exactly matching the swagger schema, so as long as we validate/lint correctly as discussed above then that shouldn't 🤞be a problem. Here's a link for the curious: |
@francocorreasosa deferring to you on merging this one. I thought / requested QL give @nik-john write, but not sure that he did. |
I'm going to be picky because we're laying foundations here that will influence everything we build on it. The POST routes should be singular to add singular entities. I.e. I've not fully reviewed it yet, but wanted to mention this before it gets accepted. |
Definitely a case of "pick one" for resource naming. Either singular (which makes POSTs and collections feel awkward) or plural (which IMO doesn't, but others may argue that it has other issues). But be consistent either way. |
@bernhard-hofmann @iansltx I think it makes sense to be consistent considering that there's no global standard for pluralization. I'll move everything to plural https://stackoverflow.com/questions/6845772/rest-uri-convention-singular-or-plural-name-of-resource-while-creating-it |
If you're posting one location, why would singular feel awkward? I think we're on the same page that the resource is either a (singular) location, group, etc, or it could be a collection of locations, groups, etc I mentioned it because the POST to locations (plural) had a description indicating it was to add a (single) location. |
I've changed all the resources to be plural. I think it makes sense to have:
|
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.
Bunch of comments here.
Main takeaways:
- Not sure we need 400s for invalid ID type. IMO that should end up as a 404; the client shouldn't care about whether an ID was a valid UUID or not.
- Flatten out route structures so you don't have to include a ton of IDs just to get to a single sub-resource. The deepest things should be is /resource/{id}/subresource, with that subresource collection containing entities that are available at the top level.
- IDs should be UUIDs across the board.
- To avoid locking things in, don't define schemas for entities that aren't referenced in endpoints.
Additionally, I'm not seeing requestBody schemas for anything, though I saw a requestBodies path referenced in at least one of the endpoints. Guessing that e.g. user creation will look a bit different than a user PATCH, so we do want to document that difference.
Finally, having a /me endpoint or similar so the currently logged in user can get their info (e.g. chapter membership, upcoming RSVP'd events, etc.) would be useful. Just in case opaque tokens end up getting used for auth, or in case a client wants to treat a JWT as opaque.
@iansltx Thanks for the detailed review. I'll make the fixes tomorrow when I get some time. TIL a lot of stuff 🙇 |
@francocorreasosa this still seems to be the pinch point for a lot of other PRs and progress. I know you can help move this along better than me so when @nik-john rejoins I'm hoping you guys can get something merged in. |
@nik-john I'm thrilled that you're learning so much. It sounds like merging this will help unblock a lot of other contributors. This is better done than perfect, if that makes sense. So I encourage us to merge as soon as we can, then make other tweaks / improvements afterward. |
@QuincyLarson Agreed. I'll try and accommodate as many changes as possible as suggested above in the next half hour and then let's plan to merge. Any further changes can be made to |
@iansltx I have addressed a bunch of stuff you brought up - could you please take a second look? I did not get the time to address a few (including the route hierarchy changes) - so I would appreciate it if you could take a stab at it. If you think that can slide for now, I would recommend getting the PR merged asap so everyone else is unblocked cc: @QuincyLarson |
This PR adds the first draft of the
swagger.json
file that enumerates the Open API specs for the Chapter UI project.PS: The document is not complete and the reason why I am raising this PR is so no one else is working on this in parallel. Please commit your open API spec changes to this PR
#17
EVERYONE IS WELCOME to commit to this PR with improvements - this is very WIP with lots of rough edges. Because I don't have a lot of time to spend on this, the idea was to just get this off the ground so we can make it better as we go along