microsoft / kiota

OpenAPI based HTTP Client code generator
https://aka.ms/kiota/docs
MIT License
2.82k stars 192 forks source link

Class access modifiers #4788

Open NKnusperer opened 3 months ago

NKnusperer commented 3 months ago

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

Currently, all classes generated by Kiota have the public access modifier, which means they are visible to all other projects that reference them. However, the generated SDK code may just be an implementation detail that should not be exposed, so it would be appropriate to have the internal access modifier instead.

Client library/SDK language

Csharp

Describe the solution you'd like

A command line argument for kiota generate that controls the class access modifier, similar to what --class-name already does.

Additional context

No response

andrueastman commented 3 months ago

Thanks for raising this @NKnusperer

In a scenario where the generated SDK project is being referenced from another project, would you need at least the ApiClient to be public? What about the models needed to send over as payloads?

NKnusperer commented 3 months ago

Hello @andrueastman, the scenario is where the ApiClient is an implementation detail abstracted by an application specific API. Lets say we are building a karaoke application, so we need access to songs, album covers, lyrics etc. After designing an interface for each service, we implement it for, say, Spotify, Amazon Music, and Apple MusicKit. Now nobody cares about the ApiClient except the implementations, so it could be internal.

baywet commented 2 months ago

This is an interesting suggestion. We already have the mechanics to convey accessibility with the access modifier enum, it's simply not implemented for class/enum/interface declarations where it's currently hard coded

But adding this information to the DOM, using it to emit the right modifier, and setting the value from an optional CLI parameter should be trivial.

Is this something you'd be willing to submit a pull request for provided with guidance?

NKnusperer commented 2 months ago

Thank you @baywet, I will definitely take a look at this 👍

haverjes commented 1 week ago

I was looking for the exact same feature is there any estimate on if or when this might be available?