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

Support generating ESM OpenAPI clients #4476

Open
sven-petersen opened this issue Feb 7, 2024 · 2 comments
Open

Support generating ESM OpenAPI clients #4476

sven-petersen opened this issue Feb 7, 2024 · 2 comments
Labels
feature request Requests for new functionality

Comments

@sven-petersen
Copy link

sven-petersen commented Feb 7, 2024

Is your feature request related to a problem? Please describe.

We want to setup a new Typescript Node project using the newer ESM syntax. We also want to generate an OpenAPI client using the Cloud SDK that then shall be used in the Node project. The generated client however uses relative imports without file extensions like so

// ./generated-client/index.ts
export * from "./some-file";

When using the ESM syntax it is required to specify the file extension for relative imports. So when the client is (re-)generated it currently is required to manually add the .js file extension to all relative import statements.

Describe the solution you'd like

It would be nice to e.g. a flag for the generator to choose between ESM and CommonJS (import) syntax. Or generally any way to make the generated code work with an ESM based project without having to make manual changes.

Describe alternatives you've considered

  • Switching the whole project to use CommonJS
  • Manually adding the missing file extensions

Impact / Priority

Additional context

@sven-petersen sven-petersen added the feature request Requests for new functionality label Feb 7, 2024
@marikaner
Copy link
Contributor

Hey @sven-petersen, thank you for the suggestion, we will discuss it. The ESM topic is generally on our radar as well 😊

@marikaner
Copy link
Contributor

We have discussed this and took it into our backlog. This will require a bit of investigation to understand whether just switching the endings for the imports is enough. Also, we would have to add a few more tests for ESM.
Generally, I think your proposal to do this with a flag makes a lot of sense, so thank you for that. From the viewpoint of the SDK this would be a feature that is interesting for both the OpenAPI and the OData generator.

Still, for now, I cannot give you a timeline, when this might be worked on.

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

No branches or pull requests

2 participants