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

[http-server-csharp] Support omit-unreachable-types setting in config to exclude types not used in operations #5126

Open
ArcturusZhang opened this issue Nov 15, 2024 · 2 comments
Labels
emitter:service:csharp feature New feature or request
Milestone

Comments

@ArcturusZhang
Copy link
Member

I am generating the petstore spec,
the model PetId is not really used, we use it to spread it as parameters:

op create(...PetId): Pet;

but this model is actually not used.
The server gen still generates it, and it cannot compile because this model has a property with the same name as the model.

public partial class PetId
{
	public int PetId {get; set;} // this will not compile.
}

Either, the server gen should not generate the model that is not used, or we should do something on the generated model to ensure it never has a property with the same name as its enclosing type.
Or I think we should do both.

@markcowl markcowl self-assigned this Nov 18, 2024
@markcowl markcowl added the feature New feature or request label Nov 18, 2024
@markcowl markcowl added this to the Backlog milestone Nov 18, 2024
@markcowl
Copy link
Contributor

@ArcturusZhang This is currently by design. Using an alias will prevent such a type from being emitted. Eventually, I think all emitters should have an equivalent of the omit-unreachable-types setting that limits the generated types to those that are reachable from operations. But generating all user-supplied types should be the default.

Keeping this issue to track omit-unreachable-types as a setting

@markcowl markcowl removed their assignment Nov 18, 2024
@markcowl markcowl changed the title [http-server-csharp] Spread but unused models are generated [http-server-csharp] Support omit-unreachable-types setting in config to exclude types not used in operations Nov 18, 2024
@ArcturusZhang
Copy link
Member Author

@ArcturusZhang This is currently by design. Using an alias will prevent such a type from being emitted. Eventually, I think all emitters should have an equivalent of the omit-unreachable-types setting that limits the generated types to those that are reachable from operations. But generating all user-supplied types should be the default.

Keeping this issue to track omit-unreachable-types as a setting

make sense. C# generator has this setting, unreference-type-handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:service:csharp feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants