////////////////////////////////////////////////////////////
// http://localhost:9090/foo-api/docs
{
"apiVersion": "0.5",
"swaggerVersion": "1.2",
"apis": [
{
"path": "/bars",
"description": "The Bar API"
}
],
"authorizations": {
"foo-api": {
"type": "oauth2",
"scopes": [
{
"scope": "foo-api"
}
],
"grantTypes": {
"authorization_code": {
"type": "authorization_code",
"tokenRequestEndpoint": {
"url": "/v0.5/token",
"clientIdName": "client_key",
"clientSecretName": "client_secret"
}
}
}
}
}
}
////////////////////////////////////////////////////////////
// http://localhost:9090/foo-api/docs/bars
{
"apiVersion": "0.5",
"swaggerVersion": "1.2",
"resourcePath": "/v0.5/bars",
"produces": [
"application/json"
],
"consumes": [
"application/json"
],
"protocols": [
"http"
],
"authorizations": [
{
"scope": "foo-api"
}
],
"apis": [
{
"path": "/v0.5/bars/",
"operations": [
{
"method": "GET",
"summary": "Get a list of bars",
"position": 0,
"notes": "",
"deprecated": false,
"nickname": "Get a list of bars",
"parameters": [],
"authorizations": [
{
"scope": "foo-api"
}
],
"type": "BarResultSet"
}
]
}
}
}
"authorizations" : {
"local-oauth": {
"type": "oauth2",
"authorizations": {
"oauth2": {
"type": "oauth2"
@model.oauth = null
if @model.authorizations
for k, v of @model.authorizations
if k == "oauth2"
if @model.oauth == null
@model.oauth = {}
if @model.oauth.scopes is undefined
@model.oauth.scopes = []
for o in v
@model.oauth.scopes.push o
As far as I can tell, you can basically support all grant flows with those two endpoints. The difference between them will be with the parameters sent to them, and those are completely controlled by the client performing the authorization.
Currently, the swagger specification officially supports only the first two grant flows, but as you can see, we can easily modify it to support all four.
I would suggest it looks like:
"authorizations" : {
"auth_name" : {
"type" : "oauth2",
"scopes" : ["scope1", "scope2", "..."],
"authorizationEndpoint" : "https://....",
"tokenEndpoint" : "https://....",
"grantFlows" : ["Authorization Code", "Implicit", "Resource Owner Password Credentials", "Client Credentials"]
}
}
If the server uses different authorization and token endpoints for different grant flows, then they could just create a different "auth_name" per set.
It's a good idea to keep the "scopes" there as this is metadata the developers may need to develop the app. In fact, we may want to expand on each scope giving an additional description to them so that the developer knows which scope means what.
One important difference between that and the current implementation is that it does not include the "tokenName", "clientIdName" and "clientSecretName" parameters. As far as I understand, those are meant to allow some flexibility in deciding what these parameters can be called. However, if I've read the oauth2 spec correctly, they are always "access_token", "client_id" and "client_secret" (respectively). In other words, the oauth2 spec doesn't allow flexibility in the naming convention and as such, we don't need to allow that in the swagger spec as well.
Please share your thoughts on the matter.
--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "Swagger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swagger-swaggersocket/WdMcNhTET_s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to a topic in the Google Groups "Swagger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swagger-swaggersocket/WdMcNhTET_s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to swagger-swaggersocket+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.