-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 fails swagger validation #4010
Comments
I'm sure many here already know this, but I finally realized that we're also getting a validation error at the bottom of https://try.gitea.io/api/swagger. If you click on the little red "Error" badge at the bottom of the page, you get a set of errors from swagger.io's own validator: https://online.swagger.io/validator/debug?url=https://try.gitea.io/swagger.v1.json |
Yes, this is mostly some description missing and few corner case like This could maybe easely fix by updating comments that are used to generate the json with https://github.com/go-swagger/go-swagger |
Starting work on these. For future reference, a quick way to get an easy-to-read list of errors from the swagger.io online validator is: curl -X POST -d @public/swagger.v1.json -H 'Content-Type:application/json' http://online.swagger.io/validator/debug | json2yaml |
So far it appears that at least some of these are more than just missing/wrong comments -- unless I'm misunderstanding something, the /responses/* errors are related to missing code. It's been a couple of days since I had a chance to look, but iirc those comments need to point at code that I couldn't find and may not exist yet. It could be that just adding a description field will make the validator happy, but I haven't had a chance to try that yet. |
Some comments especially responses are under https://github.com/go-gitea/go-sdk that is under vendor/ in gitea repo. |
* Partial fix for go-gitea#4010 Swagger needs a comment line above each swagger:response comment -- it uses these to populate the description: fields. Adding minimal text for now on the way to getting swagger validate to pass. Many standard swagger client libraries will not work at all with gitea until validate passes, so prioritizing that over better descriptions for now. Signed-off-by: Steve Traugott <stevegt@t7a.org>
This local command provides a more comprehensive error list than the swagger.io online validator command I mention above, and the output is equally easy to read: swagger validate public/swagger.v1.json |
* Partial fix for go-gitea#4010 Swagger needs a description field in each swagger:operation response. Adding minimal text for now on the way to getting swagger validate to pass. Many standard swagger client libraries will not work with gitea until validate passes, so prioritizing that over better descriptions for now. Signed-off-by: Steve Traugott <stevegt@t7a.org>
* Partial fix for #4010 Swagger needs a comment line above each swagger:response comment -- it uses these to populate the description: fields. Adding minimal text for now on the way to getting swagger validate to pass. Many standard swagger client libraries will not work at all with gitea until validate passes, so prioritizing that over better descriptions for now. Signed-off-by: Steve Traugott <stevegt@t7a.org>
* Partial fix for #4010 Swagger needs a description field in each swagger:operation response. Adding minimal text for now on the way to getting swagger validate to pass. Many standard swagger client libraries will not work with gitea until validate passes, so prioritizing that over better descriptions for now. Signed-off-by: Steve Traugott <stevegt@t7a.org>
* Partial fix for go-gitea#4010 Swagger validation needs 'required: true' for parameters that are in the URL path. Signed-off-by: Steve Traugott <stevegt@t7a.org>
* Partial fix for #4010 Swagger validation needs 'required: true' for parameters that are in the URL path. Signed-off-by: Steve Traugott <stevegt@t7a.org>
Fix all the resting errors to have a valid swagger file. They are still some warnings but nothing blocking. Doing so I found that some request still misses son parameters for some POST/PUT/PATCH request. This means the a client generated from the swagger file will not work completely. Fix #4088 by activating validation in drone Should fix #4010.
Thanks for the fixes - the definition still contains some errors: "security": [
{
"BasicAuth": [
"[]"
]
},
{
"Token": [
"[]"
]
},
{
"AccessToken": [
"[]"
]
},
{
"AuthorizationHeaderToken": [
"[]"
]
}
] The scopes arrays themselves should be empty, they should not contain strings with the value |
@MikeRalphson this should be fixed in #4236 |
* fixes a warning remaining from go-gitea#4010 and go-gitea#4220
Either I'm doing something wrong or the API (as of d94472e) is not currently emitting swagger-compliant JSON. This is causing problems when trying to use various parsers and client generators/libraries to create gitea clients, as they try to validate when parsing. The error messages I'm getting vary by library, but as a simple check, try this:
I've tried other parsers and validators, both CLI and online, and get different errors; still trying to figure out if there's any common denominator other than PEBCAK. Anyone else seeing this?
The text was updated successfully, but these errors were encountered: