Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle other implementations #2

Open
abergmeier opened this issue Apr 27, 2018 · 3 comments
Open

Handle other implementations #2

abergmeier opened this issue Apr 27, 2018 · 3 comments

Comments

@abergmeier
Copy link

To me the question is how to handle other openapi implementations e.g. go-swagger? We have prel. support in rules_go since it needs the go toolchain.

@softprops
Copy link
Contributor

softprops commented Apr 28, 2018

This project is current based on swagger. I'm not familiar with go-swagger or what differentiates it from swagger. Swagger supports arbitrary programming languages and is extensible in allowing you to define your own code generators. We actually do this with our own scala client and server generators at Meetup.

Here is an example client generator

load(
    "@io_bazel_rules_openapi//openapi:openapi.bzl",
    "openapi_gen",
)

load(
    "@io_bazel_rules_scala//scala:scala.bzl",
    "scala_library",
)

# helpers for meetup classic's common case
_base_package = "com.meetup"
def openapi_client(svc):
    openapi_gen(
        name = "{svc}-client-src".format(svc=svc),
        api_package = "{base_package}.{svc}.api".format(base_package = _base_package, svc = svc),
        invoker_package = "{base_package}.{svc}".format(base_package = _base_package, svc = svc),
        language = "meetup-scala-client",
        model_package = "{base_package}.{svc}.model".format(base_package = _base_package, svc = svc),
        spec = "src/main/openapi/meetup-scala-client/{svc}.yaml".format(svc = svc),
        deps = [
            "@meetuplib//:meetup-scala-generator",
        ],
    )

    scala_library(
        name = "{svc}-client".format(svc=svc),
        srcs = ["{svc}-client-src".format(svc=svc)],
        deps = ["@meetuplib//:meetup-scala-gen-deps"],
        visibility = ["//visibility:public"],
    )

Can you elaborate a bit more on go-swagger and how it differs in goals from swagger proper?

@tony-scio
Copy link

tony-scio commented Feb 25, 2020

I'm not sure if this is exactly the OP's question, but I'd like to be able to use this rule to generate both typescript-fetch and go libraries (as supported by swagger-codegen -l ...). In other words:

openapi_gen(
    language = "go",
    # ...
)

But it seems like the openapi_gen rule always packages the generated files into a jar, which I don't think can be easily consumed by languages other than java/scala. Am I missing an obvious way to depend on and openapi_gen rule from another language?

@softprops
Copy link
Contributor

We've only implemented what we've needed, in our case jvm bundles. The underlying tool itself supports a number of languages. What would be the ideal archive type you'd be looking for?

I could help guide you on how to add support for other package types. The current format of is implemented here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants