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

Provide a way to hook into the Services generation proces #4715

Open
uroslates opened this issue May 27, 2024 · 1 comment
Open

Provide a way to hook into the Services generation proces #4715

uroslates opened this issue May 27, 2024 · 1 comment
Labels
feature request Requests for new functionality prio: low

Comments

@uroslates
Copy link

Is your feature request related to a problem? Please describe.
When the generation process is triggered there might be a need to, in addition to the ts types & apis (services) generation, also provide an async 'hook' function which would allow the sdk consumers to register their own code doing any extra generation specifically related to the public api layer.
As an example our team's requirement is exposing the api's as public procedures. Implementing this through this kind of hooks (if provided) would eliminate lots of potential problems we might have if not using this approach (like performance optimisation or more importantly maintainance issues we could have if using parsers different than the one used internally by the sap cloud sdk.

Describe the solution you'd like
When using the sap cloud js sdk (programatically only) it would be great to provide a js hook configuration option where the consumers could provide a custom function, that would be triggered during each api/service generation iteration, where they could register thier custom (generation) code enabling them to reuse sap cloud sdk js parsed schema. Here is an possible example:

await generate({
    input: '/path/to/openapi/schemas/open-api-schema.json',
    outputDir: '/path/to/output/',
    skipValidation: true,
    generationHook: async function (
      serviceDirPath: string,
      serviceName: string,
      apiServiceName: string,
      api: any,
      options: CreateFileOptions
    ) {
      await RpcProcedureBuilder.generateProcedure(
        '/path/to/generated/procedures/folder/',
        serviceName,
        apiServiceName,
        api,
        options
      );
    },
    clearOutputDir: true
  });

Describe alternatives you've considered
Use custom solution not relying to cloud sdk parsing & generation which as described above has its negative implications.

@marikaner
Copy link
Contributor

Hey @uroslates, thank you for your contribution. We need to check how and if we can integrate your proposal and whether your approach fits our API. This will take us some time, but we will let you know as soon as we can.

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 prio: low
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants