-
-
Notifications
You must be signed in to change notification settings - Fork 602
Open
Labels
enhancementNew feature or requestNew feature or requestopenapi-tsRelevant to the openapi-typescript libraryRelevant to the openapi-typescript library
Description
Description
The current problem with --empty-objects-unknown is, that Empty objects are either fully respresented as "never" or as "any". Even though it might be preferrable to just completely ignore them.
E.g.: assume I have the following Entity structure which I expose on a Controller...
public abstract class PolicyEntity<TEntity> : IEntity
{
public abstract int Id { get; set; }
}
public class Plant : PolicyEntity<Plant>
{
public override int Id { get; set; }
}
[HttpGet("Get/{id}")]
public ActionResult<Plant>? Get([FromRoute] int id)
{
// ...
}Then I convert this to equivalent Typescript Code and get something like this:
export type components = {
schemas: {
PolicyEntity_Plant_: Record<string, unknown>;
Plant: components['schemas']['PolicyEntity_Plant_'] & ({
/** Format: int32 */
Id: number;
}
}
}which essentially means, that Schema<'Plant'>.Id and all other Properties are ALWAYS any.
Proposal
Instead, there should be aflag to fully ignore empty objects and "strip" them from the source, instead of having them as eiher Record<string, unknown> OR Record<string, never>.
Extra
Might be verry similar to this issue and provide a possible solution for: #1520
- I’m willing to open a PR (see CONTRIBUTING.md)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestopenapi-tsRelevant to the openapi-typescript libraryRelevant to the openapi-typescript library