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

[FEATURE] (type-safe-api) only require OpenApi Generator when API changes #819

Open
1 of 2 tasks
jstrunk opened this issue Aug 1, 2024 · 3 comments
Open
1 of 2 tasks
Labels

Comments

@jstrunk
Copy link
Contributor

jstrunk commented Aug 1, 2024

Describe the feature

Enable generated type-safe-api code to optionally be committed to the repo and only run OpenAPI Generator when the api spec is modified.

Use Case

I've heard developers say they are hesitant to adopt type-safe-api because it adds a dependency on the JDK and maven and that could be an issue for their customers. By committing the generated code, only developers who modify the API spec will need those dependencies.

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

PDK version used

0.23.47

What languages will this feature affect?

Typescript, Java, Python

Environment details (OS name and version, etc.)

macos

@abest0
Copy link

abest0 commented Aug 1, 2024

I believe this functionality could be helpful here in cases where one wants to provide a frozen API to a customer without passing on the additional dependencies.

I've seen cases where the team accepting the prototype consists of Data Scientists who have familiarity with Python and possibly some familiarity with JS/TS. When providing the full type-safe-api project as a deliverable (vs just the generated API), the customer must use JDK to even build the solution--this adds complexity to the delivered solution that's at odds with adoption.

I appreciate the commitGenerateCode option since it provides the ability to freeze/eject the API and just provide the generated assets.

@cogwirrel
Copy link
Member

Thanks for your contribution @jstrunk! Great to have the commitGeneratedCode option :)

I guess the next step here would be to add some logic to the various build tasks to skip codegen, though this needs a bit of thought - we ideally need a way to check whether what's generated matches the model, so that if the model changes code will be regenerated. Perhaps we generate a hash of the model and write it to the filesystem (and commit that when commitGeneratedCode is true), then at build time we regenerate the hash and proceed with codegen if the hash has changed? It'd also be nice to proceed with codegen if any generated files are missing too.

@cogwirrel
Copy link
Member

An additional note - we've replaced OpenAPI generator with our own nodejs code generation engine so there's no longer a dependency on Java and Maven for generating code. This means no java dependency at all for projects which use OpenAPI as the modelling language.

Sadly Java and Maven are still required for the Smithy build, but this still simplifies things as we'd only need to commit the .api.json and perhaps a hash of the smithy model to skip the Smithy build :) Code generation could proceed regardless as it's much faster now too :)

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

No branches or pull requests

3 participants