Skip to content

Commit

Permalink
refactor: move api.json
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Apr 26, 2021
1 parent 275d670 commit 7dc37fd
Show file tree
Hide file tree
Showing 7 changed files with 754 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ workflows:
only: master
- sdk/generate:
appname: Ory_Oathkeeper
swagpath: spec/api.json
requires:
- test
- sdk/release:
swagpath: spec/api.json
requires:
- test
- goreleaser/release
Expand All @@ -64,6 +66,7 @@ workflows:
branches:
ignore: /.*/
- docs/build:
swag-spec-location: spec/api.json
requires:
- test
filters:
Expand Down
52 changes: 30 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
SHELL=/usr/bin/env bash -o pipefail
SHELL=/bin/bash -o pipefail

export GO111MODULE := on
export PATH := .bin:${PATH}
export PWD := $(shell pwd)

.PHONY: deps
deps:
ifneq ("$(shell base64 Makefile))","$(shell cat .bin/.lock)")
go build -o .bin/go-acc github.com/ory/go-acc
go build -o .bin/goreturns github.com/sqs/goreturns
go build -o .bin/listx github.com/ory/x/tools/listx
go build -o .bin/mockgen github.com/golang/mock/mockgen
go build -o .bin/swagger github.com/go-swagger/go-swagger/cmd/swagger
go build -o .bin/goimports golang.org/x/tools/cmd/goimports
go build -o .bin/ory github.com/ory/cli
go build -o .bin/packr2 github.com/gobuffalo/packr/v2/packr2
echo "v0" > .bin/.lock
echo "$$(base64 Makefile)" > .bin/.lock
endif
GO_DEPENDENCIES = github.com/ory/go-acc \
golang.org/x/tools/cmd/goimports \
github.com/go-swagger/go-swagger/cmd/swagger \
github.com/ory/cli \
github.com/gobuffalo/packr/v2/packr2 \
github.com/go-bindata/go-bindata/go-bindata

define make-go-dependency
# go install is responsible for not re-building when the code hasn't changed
.bin/$(notdir $1): go.sum go.mod
GOBIN=$(PWD)/.bin/ go install $1
endef


.bin/clidoc: go.mod
go build -o .bin/clidoc ./cmd/clidoc/.

# Formats the code
.PHONY: format
format: deps
goreturns -w -local github.com/ory $$(listx .)
format: .bin/goimports node_modules docs/node_modules
goimports -w --local github.com/ory .
npm run format
cd docs; npm run format

.PHONY: gen
gen:
Expand All @@ -30,13 +35,13 @@ gen:
# Generates the SDKs
.PHONY: sdk
sdk: deps
swagger generate spec -m -o ./.schema/api.swagger.json -x internal/httpclient
ory dev swagger sanitize ./.schema/api.swagger.json
swagger flatten --with-flatten=remove-unused -o ./.schema/api.swagger.json ./.schema/api.swagger.json
swagger validate ./.schema/api.swagger.json
swagger generate spec -m -o ./spec/api.json -x internal/httpclient
ory dev swagger sanitize ./spec/api.json
swagger flatten --with-flatten=remove-unused -o ./spec/api.json ./spec/api.json
swagger validate ./spec/api.json
rm -rf internal/httpclient
mkdir -p internal/httpclient
swagger generate client -f ./.schema/api.swagger.json -t internal/httpclient -A Ory_Oathkeeper
swagger generate client -f ./spec/api.json -t internal/httpclient -A Ory_Oathkeeper
make format

.PHONY: install-stable
Expand Down Expand Up @@ -64,3 +69,6 @@ docker: deps
docker build -t oryd/oathkeeper:dev .
docker build -t oryd/oathkeeper:dev-alpine -f Dockerfile-alpine .
rm oathkeeper

docs/cli: .bin/clidoc
clidoc .
18 changes: 18 additions & 0 deletions cmd/clidoc/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"fmt"
"os"

"github.com/ory/x/clidoc"

"github.com/ory/oathkeeper/cmd"
)

func main() {
if err := clidoc.Generate(cmd.RootCmd, os.Args[1:]); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "%+v", err)
os.Exit(1)
}
fmt.Println("All files have been generated and updated.")
}
8 changes: 6 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ module github.com/ory/oathkeeper

replace gopkg.in/DataDog/dd-trace-go.v1 => gopkg.in/DataDog/dd-trace-go.v1 v1.27.1

replace github.com/ory/kratos/corp => github.com/ory/kratos/corp v0.0.0-20210118092700-c2358be1e867

replace github.com/ory/kratos-client-go => github.com/ory/kratos-client-go v0.5.4-alpha.1.0.20210210170256-960b093d8bf9

require (
github.com/Azure/azure-pipeline-go v0.2.2
github.com/Azure/azure-storage-blob-go v0.9.0
Expand Down Expand Up @@ -38,7 +42,7 @@ require (
github.com/mitchellh/copystructure v1.0.0
github.com/opentracing/opentracing-go v1.2.0
github.com/ory/analytics-go/v4 v4.0.1
github.com/ory/cli v0.0.10
github.com/ory/cli v0.0.49
github.com/ory/fosite v0.36.1
github.com/ory/go-acc v0.2.6
github.com/ory/go-convenience v0.1.0
Expand All @@ -48,7 +52,7 @@ require (
github.com/ory/jsonschema/v3 v3.0.1
github.com/ory/ladon v1.1.0
github.com/ory/viper v1.7.5
github.com/ory/x v0.0.163
github.com/ory/x v0.0.223
github.com/pborman/uuid v1.2.0
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions scripts/run-gensdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ rm -rf ./sdk/js/swagger

# curl -O scripts/swagger-codegen-cli-2.2.3.jar http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.3/swagger-codegen-cli-2.2.3.jar

java -jar scripts/swagger-codegen-cli-2.2.3.jar generate -i ./.schema/api.swagger.json -l go -o ./sdk/go/oathkeeper/swagger
java -jar scripts/swagger-codegen-cli-2.2.3.jar generate -i ./.schema/api.swagger.json -l javascript -o ./sdk/js/swagger
java -jar scripts/swagger-codegen-cli-2.2.3.jar generate -i ./spec/api.json -l go -o ./sdk/go/oathkeeper/swagger
java -jar scripts/swagger-codegen-cli-2.2.3.jar generate -i ./spec/api.json -l javascript -o ./sdk/js/swagger

scripts/run-format.sh

Expand Down
2 changes: 1 addition & 1 deletion scripts/run-genswag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -euo pipefail

cd "$( dirname "${BASH_SOURCE[0]}" )/.."

swagger generate spec -m -o ./.schema/api.swagger.json
swagger generate spec -m -o ./spec/api.json
Loading

0 comments on commit 7dc37fd

Please sign in to comment.