Generate swagger json - #1402
Conversation
5f70d74 to
dfdf6fa
Compare
|
Maybe we need an API docs site? Or a link on docs.gitea.io? |
|
Once fully implented we could use swagger ui for presentation. There is two choice possible :
As global documentation we could start a docker containing swagger ui (allready avalaibe) for try.gitea.io : https://github.com/swagger-api/swagger-ui |
|
I think that I will simply copy https://github.com/swagger-api/swagger-ui/tree/master/dist into public/assets. This will provide swagger-ui on all instance. |
|
@sapk so add new |
|
@lunny For generating swagger.json, I added a go generate here : So make generate will update it and place it under public folder. For swagger-ui, I am thinking of adding a other step to make assets |
|
In parallel, I will PR to fix little things like go-gitea/go-sdk#50 (it will need a PR in gitea also) to put all data structure under go-sdk and add missing api request. A other PR to go-gitea/go-sdk will be added to add swagger comment to api response and params. This PR is a long running one to complete ^^. It will maybe need a second pass to adjust comments but the base will be there. |
|
Or maybe we can add a link on the bottom or top on Gitea named |
9d6d4f2 to
cefa415
Compare
There was a problem hiding this comment.
maybe use "s;https://...;...;g" instead for readability?
There was a problem hiding this comment.
I am not a big expert in sed. ^^
There was a problem hiding this comment.
Just download a tar.gz release instead. We shouldn't depend on latest master being functional
There was a problem hiding this comment.
I use git tag now to fix the version. (less things to change ^^)
There was a problem hiding this comment.
Maybe update the doc links while you're at it :)
There was a problem hiding this comment.
Or remove them since they now become redundant 😅
There was a problem hiding this comment.
This needs to be fixed before merge :)
There was a problem hiding this comment.
Yes this temporary and will be added in a PR in sdk. All the input and output format (used by api) are in sdk and I have already done one PR to move a struct in gitea to sdk.
|
Actually, would it make sense to have this in |
|
Is this still WIP? |
|
@lunny yes because it is missing some api url and it need a PR in sdk for all format response and request. But you can review tooling around it like Makefile and the only changes that will append next are swagger comment so It will be ready to merge when complete. |
|
@sapk maybe move this to v1.3? |
|
@lunny There is two possibility :
|
|
This will have my LG-TM once the gogs docs links are gone 🙂 |
|
The swagger file is not complete. Some parts of the API are missing like the issue management. |
|
@JonasFranzDEV That what I say ^^ |
Generate swagger.json into public/ Add swagger-ui auto-installation Add footer link to local swagger-ui Add /swagger url for using app url. Fix Swagger-UI version via git tag Use a easier to understand sed syntax Vendor temporary PR for sdk
|
I rebase/squash all changes into a fully working version. I vendor go-gitea/go-sdk#53 in the wait of it validation so that this PR is working for validation also. I will revert it back as soon that go-gitea/go-sdk/pull/53 is merged. For testing, just build gitea like always, start it, and go to Fix/Hack that I have implemented : (This is if someone has a better/cleaner idea)
Improvements to be done in other PR :
Over all, this PR should not have an big impact on code functionality as it is mostly comments. |
|
@sapk I like first chosen. So is it ready to review and merge? |
|
@lunny Yes, the only thing that bother me is the little fix/hack for recursive structure not supported by swagger-ui but we need it. (describe in my previous comment) |
|
Which version are you using? We've just switched to using swagger-ui v3.0.7. Has a much nicer look. This is getting ready for OpenAPI v3.0 later in the year: http://swagger.io/new-swagger-ui-and-swagger-editor/. |
|
@KangoV I have added swagger-ui v3.0.7 (get via makefile). I used go-swagger to generate the JSON from code comments. |
|
Is this ready for review? |
|
@lunny yes like I said two days ago ^^ |
|
LGTM |
|
LGTM |
|
make LG-TM work |
Use https://github.com/go-swagger/go-swagger with go generate to (auto-)build public/swagger.json
Related : #194 go-gitea/go-sdk#53
I will fill missing API descriptions. For the responses descriptions, tags must be add to sdk repo (so in a other PR).
You can test rendering at http://editor.swagger.io and copy-paste swagger.json.
Documented API :