-
Notifications
You must be signed in to change notification settings - Fork 114
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
Are there any plans to implement swagger? #53
Comments
We have JSON Schema implemented already. Ping @smyrman for more info on how it could be used for Swagger. |
hi @smyrman, any idea how the json schema could be used for swagger? |
@omani, Swagger 2.0 uses a subset of the JSON Schema Draft4 specification to describe Data Types. Therefore, the JSON Schema support in rest-layer will eventually make it possible to describe the leagal/expected payload per API endpoint. Please note that the JSON Schema support in rest-layer is still under development, and doesn't yet handle all |
Also please note that no work has started on actually implementing Swagger API documentaiton support (as far as I am aware), which I assume would involve translating a resource.Index into a Swagger 2.0 JSON document By active use of hardcoding, you might be able to do this in a crude way for your current rest-layer based project, and then call into the JSONSchema API for the payload schema definitions. Other than that, I assume PRs are welcome:-) |
I was actually mening to refer to definition objects. Sorry about that. |
There is a new version called OpenAPI Specification 3.0.0. I have been able to generate such a file in part from I don't have time to clean it up and contribute it back into a propper PR right now, but I can dump it on a branch in case anyone else want to have a look. I will try to do this in not to long... |
Here is what we have (pretty limited/hard-coded, and influenced by #127 being open): Example usage in an application atm. (where // NewDocHandler returns a handler that writes an "openapi.json" file to the
// response, which could be used for documentation UIs.
func (api *API) NewDocHandler() (http.Handler, error) {
api.ensureIndex()
doc, err := openapi.RestlayerDoc(openapi.Info{
Title: "My Awesome API",
Description: "Allows access to awesome resources.",
Version: "0.0.1",
}, api.index)
if err != nil {
return nil, err
}
doc.Servers = []openapi.Server{
{URL: api.RootURL},
}
doc.Components.SecuritySchemes = map[string]json.RawMessage{
"jwt": openapi.SecuritySchemeJWT,
}
doc.Security = []openapi.SecurityRequirement{
{"jwt": []string{}},
}
return openapi.NewHandler(doc)
} A proper implementation within rest-layer should probably rely more on |
What I have is a bit hard-coded here and there, but we are using it for our own APIs and it works. Make sure all custom For any official Swagger support, I think it's pretty far away atm. |
Probably we are not using the exact same version that is in the gist btw... But just scream out (perhaps on slack) if you have any issues using it. Look for |
Based on @smyrman's work I created the rest-layer-openapi with some improvements;
There is still some pending work, specially on supporting more Field types and create some documentation and examples, but I think it's quite solid. An example of usage is;
|
Will close this question. |
@smyrman Shouldn't we mention somewhere in the README that rest-layer-openapi exists? |
Yes, that's probably a good idea. I am not quite confident our generated JSON-schema is a 100% valid with OpenAPI though, so we should be aware of that. |
Yes, we can decorate the link with |
Hi all,
first of all thank you for this wonderful piece of software.
I want to ask if there is any plan to implement or provide a swagger overlay.
The text was updated successfully, but these errors were encountered: