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

Generate Client for Specific Entities with in an EDMX #4931

Open
nsathya2010 opened this issue Aug 20, 2024 · 5 comments
Open

Generate Client for Specific Entities with in an EDMX #4931

nsathya2010 opened this issue Aug 20, 2024 · 5 comments
Labels
feature request Requests for new functionality

Comments

@nsathya2010
Copy link

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

I’m always cumbersome to handle too many files when I need to generate OData clients for services with multiple entities, but I only require a client for a specific entity The current generator does not support generating clients for individual entities, leading to unnecessary code and increased complexity.

Describe the solution you’d like

I would like the SAP Cloud SDK OData client generator to support an option to generate clients for specific entities only. This could be achieved by providing an --include-entity/--exclude-entity flag or similar, allowing users to specify the entities they need.

Describe alternatives you’ve considered

I have considered manually editing the generated code to remove unwanted entities, but this is time-consuming and error-prone. Another alternative is to use the include option to specify files, but this does not address the need to filter entities within a single service specification.

Impact / Priority Affected development phase: Development, increased deployment size

Impact: Inconvenience

Additional context: This feature would greatly streamline the development process by reducing the amount of unnecessary code and simplifying the client generation process. It would also help in maintaining cleaner and more manageable codebases.

@nsathya2010 nsathya2010 added the feature request Requests for new functionality label Aug 20, 2024
@nsathya2010 nsathya2010 changed the title Generate Client for Specific Entities with in an EDMK Generate Client for Specific Entities with in an EDMX Aug 20, 2024
@deekshas8
Copy link
Contributor

Hi @nsathya2010 ,

Thank you for raising this. This would indeed be a nice feature in both the generators.
I have created a backlog item for this. But given our current low capacity, I'm not sure whether we will work on this feature request anytime soon or not.

@nsathya2010
Copy link
Author

Hi @deekshas8,

Thanks for the acknowledgement.

Do you know any workaround for this. We are deploying 450 + files including transpiled JS. However, we only need 15 files max.

@nsathya2010
Copy link
Author

nsathya2010 commented Aug 21, 2024

Hi @deekshas8 ,

I have a fork and I added few lines of code to filter the entities, could you please take a look if it is any good. I had added only of the OData Generator for now.

Fork

Thanks,
Sathya

@deekshas8
Copy link
Contributor

Hi @nsathya2010 ,

Did you try this out for your service? Is it working the way you expect?

I briefly looked at the fork, and while having a list of string for entities to ignore would be the way to go, I see some potential issues.

  1. The names that the user sets in this list might not match the generated code since we do additional formatting for names in getServiceEntitiesV2 .
  2. The naming of the option selectedEntities in the common generator options since this does not entirely go with the OpenApi generator. I would like to give this a bit more thought.
  3. The new feature also needs more test coverage for all cases.

You can use the changes the at you have made if it's working for your use-case and create a PR contribution if you'd like to work on this further.
But as mentioned before, we are a bit low on capacity and I would like to do this after more careful consideration on all edge cases.

Regarding maybe reducing the number of transpiled files, you can skip generation of declaration and source map files (if you don't need them) by passing your own tsconfig. The SDK by default generates them.

@nsathya2010
Copy link
Author

Hi @deekshas8 ,

It did work for me and the generated/transpiled files are now in production as it reduced 250+files. However, my service was OData V4. I made it work my copying the /dist and generated the files programmatically (not via CLI).

Thanks for the feedback. I will go through the v2 API name mapping and think about reversing the parameter selectedEntities to ignoreEntities. Only problem is too many entities to be given in case of ignore.

I will try and make more tests and raise a PR if it is ready.

Thanks,
Sathya

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