diff --git a/Taskfile.yml b/Taskfile.yml index 36edab0..2ef4fe9 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -33,4 +33,4 @@ tasks: - docker-build desc: Generates OpenAPI entities and clients cmds: - - docker run -it -v $(pwd):/app corbado-go:latest scripts/generate-openapi.sh pkg/sdk/entity/api + - docker run -it -v $(pwd):/app corbado-go:latest scripts/generate-openapi.sh pkg/generated diff --git a/scripts/generate-openapi.sh b/scripts/generate-openapi.sh index d056f26..05f6469 100755 --- a/scripts/generate-openapi.sh +++ b/scripts/generate-openapi.sh @@ -2,18 +2,15 @@ if [ $# -ne 1 ]; then echo "USAGE: " - echo "EXAMPLE: pkg/sdk/entity/api" + echo "EXAMPLE: pkg/generated" exit 1 fi path=$1 -# download OpenAPI specs -curl -s -O https://api.corbado.com/docs/api/openapi/backend_api_public.yml +# To generate openapi client, you need to copy common.yml and backend_api_public.yml to the root of the project # generate Go entities and clients -oapi-codegen -package api -generate "types,client" backend_api_public.yml > ${path}/api.gen.go - -# remove OpenAPI specs -rm backend_api_public.yml \ No newline at end of file +oapi-codegen -package common -generate "types" common.yml > ${path}/common/common.gen.go +oapi-codegen -package api -import-mapping common.yml:github.com/corbado/corbado-go/pkg/generated/common -generate "types,client" backend_api_public.yml > ${path}/api/api.gen.go