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

build(api-client): generate java, go clients #393

Open
petermetz opened this issue Nov 20, 2020 · 8 comments · May be fixed by #2973
Open

build(api-client): generate java, go clients #393

petermetz opened this issue Nov 20, 2020 · 8 comments · May be fixed by #2973
Assignees
Labels
dependencies Pull requests that update a dependency file Developer_Experience enhancement New feature or request good-first-issue Good for newcomers Hacktoberfest Hacktoberfest participants are welcome to take a stab at issues marked with this label. Nice-to-Have P1 Priority 1: Highest
Milestone

Comments

@petermetz
Copy link
Member

Description

As a developer I want to not be forced to use the NodeJS/Javascript API client if my primary programming language is something else so that I can achieve high productivity through Cactus no matter the language I'm using.

  • This is different from a similar looking issue which discusses the possibility of writing plugins in different languages as well.
  • We do not need write much Go/Java code because 99% of it is auto-generated. See the Acceptance criteria 4)

Here is a complete list of programming languages that are supported by the OpenAPI generator (which we can take full advantage of since we are using the OpenAPI specs)
https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages

Acceptance Criteria

  1. Clients for Java and Go are generated as part of the full build
  2. Dev builds only build the Typescript API client to remain as fast as possible
  3. Publishing of the Java and Go API clients is included in the release process => if I run the release scripts the full build runs and the Java, Go clients are published/made available for public consumption the same way we do with the Typescript API client (it gets published to npm)
  4. Client side routing is supported by the Go/Java API clients as well.

cc: @takeutak @sfuji822 @jonathan-m-hamilton

@petermetz petermetz added enhancement New feature or request good-first-issue Good for newcomers dependencies Pull requests that update a dependency file Developer_Experience Hacktoberfest Hacktoberfest participants are welcome to take a stab at issues marked with this label. labels Nov 20, 2020
@petermetz petermetz added this to the v0.4.0 milestone Nov 20, 2020
@petermetz petermetz modified the milestones: v0.4.0, v0.7.0, v1.0.0 Feb 9, 2021
@petermetz
Copy link
Member Author

This blew up in complexity because the oneOf allOf keywords are not universally supported among the different OpenAPI generators the way they are for the typescript-axios generator so it's not immediately obvious how to migrate away from these unsupported keywords. The other option is to wait for them to add support (or help them implement it) so that we can just go back to a much lower complexity in the scope of this issue once those generators "just work" out of the box.

@petermetz petermetz added the P1 Priority 1: Highest label Aug 20, 2023
@petermetz petermetz self-assigned this Aug 20, 2023
@petermetz petermetz modified the milestones: v1.0.0, v2.0.0-rc.2 Aug 20, 2023
@petermetz petermetz removed their assignment Aug 23, 2023
@jagpreetsinghsasan jagpreetsinghsasan self-assigned this Sep 11, 2023
@jagpreetsinghsasan
Copy link
Contributor

For the Go artifacts, publishing the api-client code (as a commit to cacti github code) itself will act as the artifact, right?
Then we can import it something like
import cactus-cmd-api-server "github.com/hyperledger/cacti/packages/cactus-cmd-api-server/src/main/go/generated/openapi/go-client"
@petermetz is this fine?

@jagpreetsinghsasan
Copy link
Contributor

The kotlin jar generation is broken, mostly due to openapi-generator upgrade, will fix those alongwith this issue.

@petermetz
Copy link
Member Author

For the Go artifacts, publishing the api-client code (as a commit to cacti github code) itself will act as the artifact, right? Then we can import it something like import cactus-cmd-api-server "github.com/hyperledger/cacti/packages/cactus-cmd-api-server/src/main/go/generated/openapi/go-client" @petermetz is this fine?

@jagpreetsinghsasan Yes, works fine for me. Please open a follow-up issue there to mimic how it is being done for the weaver components (@sandeepnRES wrote some scripts or GH actions to do tag based releases IIRC)

@jagpreetsinghsasan
Copy link
Contributor

One of the issues I faced during generating java artifacts was that in cactus-core-api openapi specs, we have a field within JWSRecipient termed protected which matches with the Java protected keyword, thus the generated code cannot produce the respective client JAR
(I will create an issue to address the same, mentioning it for future reference)

@jagpreetsinghsasan
Copy link
Contributor

Openapi specs
image

Generated code (throwing errors)
image

@jagpreetsinghsasan
Copy link
Contributor

jagpreetsinghsasan commented Jan 4, 2024

JAR parsing for cactus-plugin-htlc-eth-besu, cactuls-plugin-htlc-eth-besu-erc20, connector-besu, connector-ethereum, connector-quorum, connector-xdai fails due to invalid Java code being generated
image

Other devs are also facing the same issue: OpenAPITools/openapi-generator#12556 (comment)

@jagpreetsinghsasan
Copy link
Contributor

jagpreetsinghsasan commented Jan 4, 2024

connector-iroha , connector-iroha2 faces yet another bug related to openapi codegen (<, > signs arent rendered correctly)
OpenAPITools/openapi-generator#11601

image

jagpreetsinghsasan added a commit to jagpreetsinghsasan/cactus that referenced this issue Jan 5, 2024
    Primary Changes
    ---------------
    1. Updated package.json of packages to include the new
       codegen scripts
    2. Added a new workflow to create and upload the jars from
       the newly added code

   Changes required to incorporate 1)
   ---------------------------------
   3. Added replace package to assist the codegen scripts
      written in package.json

Fixes hyperledger#393

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
jagpreetsinghsasan added a commit to jagpreetsinghsasan/cactus that referenced this issue Jan 11, 2024
    Primary Changes
    ---------------
    1. Updated package.json of packages to include the new
       codegen scripts
    2. Added a new workflow to create and upload the jars from
       the newly added code

   Changes required to incorporate 1)
   ---------------------------------
   3. Added replace package to assist the codegen scripts
      written in package.json

Fixes hyperledger#393

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
@jagpreetsinghsasan jagpreetsinghsasan linked a pull request Jan 11, 2024 that will close this issue
5 tasks
sandeepnRES pushed a commit to jagpreetsinghsasan/cactus that referenced this issue Jan 18, 2024
    Primary Changes
    ---------------
    1. Updated package.json of packages to include the new
       codegen scripts
    2. Added a new workflow to create and upload the jars from
       the newly added code

   Changes required to incorporate 1)
   ---------------------------------
   3. Added replace package to assist the codegen scripts
      written in package.json

Fixes hyperledger#393

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
petermetz pushed a commit to jagpreetsinghsasan/cactus that referenced this issue Jan 19, 2024
    Primary Changes
    ---------------
    1. Updated package.json of packages to include the new
       codegen scripts
    2. Added a new workflow to create and upload the jars from
       the newly added code

   Changes required to incorporate 1)
   ---------------------------------
   3. Added replace package to assist the codegen scripts
      written in package.json

Fixes hyperledger#393

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file Developer_Experience enhancement New feature or request good-first-issue Good for newcomers Hacktoberfest Hacktoberfest participants are welcome to take a stab at issues marked with this label. Nice-to-Have P1 Priority 1: Highest
Projects
Status: In review
Development

Successfully merging a pull request may close this issue.

2 participants