Skip to content

Commit

Permalink
sdk: Upgrade swagger and resolve PHP SDK issues (ory#1535)
Browse files Browse the repository at this point in the history
Closes ory#1480

Closes ory#1532

Closes ory#1508
  • Loading branch information
aeneasr authored Aug 19, 2019
1 parent d1343ae commit d4a7d6b
Show file tree
Hide file tree
Showing 216 changed files with 2,425 additions and 8,277 deletions.
20 changes: 7 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ SHELL=/bin/bash -o pipefail
.PHONY: tools
tools:
npm i
go get github.com/go-bindata/go-bindata/go-bindata
go install github.com/go-bindata/go-bindata/go-bindata
go get github.com/ory/go-acc
go install github.com/ory/go-acc
go install github.com/ory/go-acc github.com/ory/x/tools/listx github.com/go-swagger/go-swagger/cmd/swagger github.com/go-bindata/go-bindata/go-bindata github.com/sqs/goreturns

# Runs full test suite including tests where databases are enabled
.PHONY: test
Expand Down Expand Up @@ -67,7 +64,7 @@ quicktest:
# Formats the code
.PHONY: format
format:
goreturns -w -local github.com/ory $$(listx .)
$$(go env GOPATH)/bin/goreturns -w -local github.com/ory $$($$(go env GOPATH)/bin/listx .)
npm run format

# Generates mocks
Expand All @@ -90,22 +87,19 @@ gen: mocks sqlbin sdk
# Generates the SDKs
.PHONY: sdk
sdk:
rm -rf ./vendor/
GO111MODULE=on go mod tidy
GO111MODULE=on go mod vendor
GO111MODULE=off swagger generate spec -m -o ./docs/api.swagger.json -x sdk
GO111MODULE=off swagger validate ./docs/api.swagger.json
$$(go env GOPATH)/bin/swagger generate spec -m -o ./docs/api.swagger.json -x sdk
$$(go env GOPATH)/bin/swagger validate ./docs/api.swagger.json

rm -rf ./sdk/go/hydra/client
rm -rf ./sdk/go/hydra/models
rm -rf ./sdk/js/swagger
rm -rf ./sdk/php/swagger
rm -rf ./sdk/java

GO111MODULE=off swagger generate client -f ./docs/api.swagger.json -t sdk/go/hydra -A Ory_Hydra
$$(go env GOPATH)/bin/swagger generate client -f ./docs/api.swagger.json -t sdk/go/hydra -A Ory_Hydra
java -jar scripts/swagger-codegen-cli-2.2.3.jar generate -i ./docs/api.swagger.json -l javascript -o ./sdk/js/swagger
java -jar scripts/swagger-codegen-cli-2.2.3.jar generate -i ./docs/api.swagger.json -l php -o sdk/php/ \
--invoker-package HydraSDK --git-repo-id swagger --git-user-id ory --additional-properties "packagePath=swagger,description=Client for Hydra"
--invoker-package Hydra\\SDK --git-repo-id swagger --git-user-id ory --additional-properties "packagePath=swagger,description=Client for Hydra"
java -DapiTests=false -DmodelTests=false -jar scripts/swagger-codegen-cli-2.2.3.jar generate \
--input-spec ./docs/api.swagger.json \
--lang java \
Expand All @@ -117,7 +111,7 @@ sdk:
--model-package com.github.ory.hydra.model \
--output ./sdk/java/hydra-client-resttemplate

cd sdk/go; goreturns -w -i -local github.com/ory $$(listx .)
make format

rm -f ./sdk/js/swagger/package.json
rm -rf ./sdk/js/swagger/test
Expand Down
2 changes: 1 addition & 1 deletion client/sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func createTestClient(prefix string) *models.Client {
Scope: prefix + "foo bar baz",
TermsOfServiceURI: prefix + "tos-uri",
ResponseTypes: []string{prefix + "id_token", prefix + "code"},
RedirectUris: []string{"https://" + prefix + "redirect-url", "https://" + prefix + "redirect-uri"},
RedirectURIs: []string{"https://" + prefix + "redirect-url", "https://" + prefix + "redirect-uri"},
SecretExpiresAt: 0,
TokenEndpointAuthMethod: "client_secret_basic",
UserinfoSignedResponseAlg: "none",
Expand Down
6 changes: 3 additions & 3 deletions cmd/cli/handler_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (h *ClientHandler) CreateClient(cmd *cobra.Command, args []string) {
ResponseTypes: flagx.MustGetStringSlice(cmd, "response-types"),
Scope: strings.Join(flagx.MustGetStringSlice(cmd, "scope"), " "),
GrantTypes: flagx.MustGetStringSlice(cmd, "grant-types"),
RedirectUris: flagx.MustGetStringSlice(cmd, "callbacks"),
RedirectURIs: flagx.MustGetStringSlice(cmd, "callbacks"),
Name: flagx.MustGetString(cmd, "name"),
TokenEndpointAuthMethod: flagx.MustGetString(cmd, "token-endpoint-auth-method"),
JSONWebKeysURI: flagx.MustGetString(cmd, "jwks-uri"),
Expand All @@ -118,7 +118,7 @@ func (h *ClientHandler) CreateClient(cmd *cobra.Command, args []string) {
AllowedCORSOrigins: flagx.MustGetStringSlice(cmd, "allowed-cors-origins"),
SubjectType: flagx.MustGetString(cmd, "subject-type"),
Audience: flagx.MustGetStringSlice(cmd, "audience"),
PostLogoutRedirectUris: flagx.MustGetStringSlice(cmd, "post-logout-callbacks"),
PostLogoutRedirectURIs: flagx.MustGetStringSlice(cmd, "post-logout-callbacks"),
}

response, err := m.Admin.CreateOAuth2Client(admin.NewCreateOAuth2ClientParams().WithBody(&cc))
Expand Down Expand Up @@ -202,7 +202,7 @@ func (h *ClientHandler) ListClients(cmd *cobra.Command, args []string) {
cl.Name,
strings.Join(cl.ResponseTypes, ","),
cl.Scope,
strings.Join(cl.RedirectUris, "\n"),
strings.Join(cl.RedirectURIs, "\n"),
strings.Join(cl.GrantTypes, ","),
cl.TokenEndpointAuthMethod,
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
_ "golang.org/x/tools/cmd/goimports"
_ "golang.org/x/tools/cmd/stringer"

_ "github.com/sqs/goreturns"

_ "github.com/ory/go-acc"
_ "github.com/ory/x/tools/listx"
)
182 changes: 8 additions & 174 deletions docs/api.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
"application/json"
],
"tags": [
"health"
"admin"
],
"summary": "Check alive status",
"operationId": "isInstanceAlive",
Expand All @@ -372,7 +372,7 @@
"application/json"
],
"tags": [
"health"
"public"
],
"summary": "Check readiness status",
"operationId": "isInstanceReady",
Expand Down Expand Up @@ -1799,7 +1799,7 @@
"application/json"
],
"tags": [
"version"
"admin"
],
"summary": "Get service version",
"operationId": "getVersion",
Expand Down Expand Up @@ -1922,6 +1922,7 @@
},
"JSONWebKeySet": {
"type": "object",
"title": "JSONWebKeySet represents a JWK Set object.",
"properties": {
"keys": {
"description": "The value of the \"keys\" parameter is an array of JWK values. By\ndefault, the order of the JWK values within the array does not imply\nan order of preference among them, although applications of JWK Sets\ncan choose to assign a meaning to the order for their purposes, if\ndesired.",
Expand All @@ -1933,7 +1934,7 @@
}
},
"x-go-name": "swaggerJSONWebKeySet",
"x-go-package": "github.com/ory/hydra/jwk"
"x-go-package": "gopkg.in/square/go-jose.v2"
},
"PreviousConsentSession": {
"description": "The response used to return used consent requests\nsame as HandledLoginRequest, just with consent_request exposed as json",
Expand Down Expand Up @@ -2168,11 +2169,6 @@
"x-go-name": "ConsentRequestSessionData",
"x-go-package": "github.com/ory/hydra/consent"
},
"emptyResponse": {
"description": "Empty responses are sent when, for example, resources are deleted. The HTTP status code for empty responses is\ntypically 201.",
"type": "object",
"x-go-package": "github.com/ory/hydra"
},
"flushInactiveOAuth2TokensRequest": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -2235,7 +2231,7 @@
}
},
"x-go-name": "swaggerNotReadyStatus",
"x-go-package": "github.com/ory/hydra/vendor/github.com/ory/x/healthx"
"x-go-package": "github.com/ory/x/healthx"
},
"healthStatus": {
"type": "object",
Expand All @@ -2247,7 +2243,7 @@
}
},
"x-go-name": "swaggerHealthStatus",
"x-go-package": "github.com/ory/hydra/vendor/github.com/ory/x/healthx"
"x-go-package": "github.com/ory/x/healthx"
},
"jsonWebKeySetGeneratorRequest": {
"type": "object",
Expand Down Expand Up @@ -2772,168 +2768,6 @@
"x-go-name": "RequestDeniedError",
"x-go-package": "github.com/ory/hydra/consent"
},
"swaggerFlushInactiveAccessTokens": {
"type": "object",
"properties": {
"Body": {
"$ref": "#/definitions/flushInactiveOAuth2TokensRequest"
}
},
"x-go-package": "github.com/ory/hydra/oauth2"
},
"swaggerJsonWebKeyQuery": {
"type": "object",
"required": [
"kid",
"set"
],
"properties": {
"kid": {
"description": "The kid of the desired key\nin: path",
"type": "string",
"x-go-name": "KID"
},
"set": {
"description": "The set\nin: path",
"type": "string",
"x-go-name": "Set"
}
},
"x-go-package": "github.com/ory/hydra/jwk"
},
"swaggerJwkCreateSet": {
"type": "object",
"required": [
"set"
],
"properties": {
"Body": {
"$ref": "#/definitions/jsonWebKeySetGeneratorRequest"
},
"set": {
"description": "The set\nin: path",
"type": "string",
"x-go-name": "Set"
}
},
"x-go-package": "github.com/ory/hydra/jwk"
},
"swaggerJwkSetQuery": {
"type": "object",
"required": [
"set"
],
"properties": {
"set": {
"description": "The set\nin: path",
"type": "string",
"x-go-name": "Set"
}
},
"x-go-package": "github.com/ory/hydra/jwk"
},
"swaggerJwkUpdateSet": {
"type": "object",
"required": [
"set"
],
"properties": {
"Body": {
"$ref": "#/definitions/JSONWebKeySet"
},
"set": {
"description": "The set\nin: path",
"type": "string",
"x-go-name": "Set"
}
},
"x-go-package": "github.com/ory/hydra/jwk"
},
"swaggerJwkUpdateSetKey": {
"type": "object",
"required": [
"kid",
"set"
],
"properties": {
"Body": {
"$ref": "#/definitions/JSONWebKey"
},
"kid": {
"description": "The kid of the desired key\nin: path",
"type": "string",
"x-go-name": "KID"
},
"set": {
"description": "The set\nin: path",
"type": "string",
"x-go-name": "Set"
}
},
"x-go-package": "github.com/ory/hydra/jwk"
},
"swaggerOAuthIntrospectionRequest": {
"type": "object",
"required": [
"token"
],
"properties": {
"scope": {
"description": "An optional, space separated list of required scopes. If the access token was not granted one of the\nscopes, the result of active will be false.\n\nin: formData",
"type": "string",
"x-go-name": "Scope"
},
"token": {
"description": "The string value of the token. For access tokens, this\nis the \"access_token\" value returned from the token endpoint\ndefined in OAuth 2.0. For refresh tokens, this is the \"refresh_token\"\nvalue returned.",
"type": "string",
"x-go-name": "Token"
}
},
"x-go-package": "github.com/ory/hydra/oauth2"
},
"swaggerRevokeOAuth2TokenParameters": {
"type": "object",
"required": [
"token"
],
"properties": {
"token": {
"description": "in: formData",
"type": "string",
"x-go-name": "Token"
}
},
"x-go-package": "github.com/ory/hydra/oauth2"
},
"swaggeroauth2TokenParameters": {
"type": "object",
"required": [
"grant_type"
],
"properties": {
"client_id": {
"description": "in: formData",
"type": "string",
"x-go-name": "ClientID"
},
"code": {
"description": "in: formData",
"type": "string",
"x-go-name": "Code"
},
"grant_type": {
"description": "in: formData",
"type": "string",
"x-go-name": "GrantType"
},
"redirect_uri": {
"description": "in: formData",
"type": "string",
"x-go-name": "RedirectURI"
}
},
"x-go-package": "github.com/ory/hydra/oauth2"
},
"userinfoResponse": {
"description": "The userinfo response",
"type": "object",
Expand Down Expand Up @@ -3048,7 +2882,7 @@
}
},
"x-go-name": "swaggerVersion",
"x-go-package": "github.com/ory/hydra/vendor/github.com/ory/x/healthx"
"x-go-package": "github.com/ory/x/healthx"
},
"wellKnown": {
"description": "It includes links to several endpoints (e.g. /oauth2/token) and exposes information on supported signature algorithms\namong others.",
Expand Down
Loading

0 comments on commit d4a7d6b

Please sign in to comment.