-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Generate swagger json #1402
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
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
Makefile
Outdated
git clone --depth=10 https://github.com/swagger-api/swagger-ui.git /tmp/swagger-ui | ||
mv /tmp/swagger-ui/dist public/assets/swagger-ui | ||
rm -Rf /tmp/swagger-ui | ||
sed -i "s/http:\/\/petstore.swagger.io\/v2\/swagger.json/..\/..\/swagger.v1.json/g" public/assets/swagger-ui/index.html |
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.
maybe use "s;https://...;...;g"
instead for readability?
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.
I am not a big expert in sed. ^^
Makefile
Outdated
rm -Rf public/assets/swagger-ui | ||
git clone --depth=10 https://github.com/swagger-api/swagger-ui.git /tmp/swagger-ui | ||
mv /tmp/swagger-ui/dist public/assets/swagger-ui | ||
rm -Rf /tmp/swagger-ui |
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.
Just download a tar.gz release instead. We shouldn't depend on latest master being functional
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.
I use git tag now to fix the version. (less things to change ^^)
routers/api/v1/misc/markdown.go
Outdated
@@ -15,6 +15,18 @@ import ( | |||
// Markdown render markdown document to HTML | |||
// see https://github.com/gogits/go-gogs-client/wiki/Miscellaneous#render-an-arbitrary-markdown-document |
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.
Maybe update the doc links while you're at it :)
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.
Or remove them since they now become redundant 😅
vendor/vendor.json
Outdated
@@ -9,10 +9,13 @@ | |||
"revisionTime": "2017-04-07T07:44:04Z" | |||
}, | |||
{ | |||
"checksumSHA1": "32qRX47gRmdBW4l4hCKGRZbuIJk=", | |||
"checksumSHA1": "oUPCyOhO8e61S2KVMJzM8sDnFdA=", | |||
"origin": "github.com/sapk-fork/gitea-go-sdk/gitea", |
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.
This needs to be fixed before merge :)
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.
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 :