spacecloud-io / space-cloud

Open source Firebase + Heroku to develop, scale and secure serverless apps on Kubernetes
https://space-cloud.io
Apache License 2.0
3.95k stars 222 forks source link

[Feature] Add support for typescript client generator #1661

Closed YourTechBud closed 1 year ago

YourTechBud commented 1 year ago

The problem faced currently?

How can we solve it?

If you want this feature to be implemented, give it a thumbs up reaction, so that we can determine which features are important to you. 👍

ivstrand commented 1 year ago

I just run this in a vscode/devcontainer-docker In docker.compose.yml

 openapi_generator:
    image: openapitools/openapi-generator-cli
    volumes:
      - ./openapi:/openapi:ro,consistent

Trigger with this shell script, more options are possible and apparently 40 langs:

I use this in a small "dockerapp.sh" file:

# codeGen for SDK:   ./dockerapp.sh --sdk
# alt first line for cli input:  docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate \
if [ "$1" = "--sdk" ]; then
    root=$pwd
    docker run --rm -v $root:/local openapitools/openapi-generator-cli generate  \
    -i /local/openapi/swagger.yml \
    -g typescript-fetch \
    -o /local/openapi/sdk/ts
fi

I find the output relatively verbose...but useful. The tool only supports swagger 2.0 json schemas, not 3.0 as the space-cloud seems to be documented with.

YourTechBud commented 1 year ago

Thanks for the suggestion @ivstrand.

We did consider the openapi generator for typescript but didn't go ahead with this for the following reasons:

The idea is to not discourage use of open api generators. Users of SpaceCloud are free to continue using them. We just have some in-built set of generates which we feel work great for some use case.

@shubham4443 what if we add support for openapi generator in spacectl? This way we can use our generators for the languages we support and leverage the communities work for the languages we don't.