Proxy Generation - Required and Optional Fields
Is there an existing issue for this?
- I have searched the existing issues
Description
Generating proxy in angular for such class
public class CarDto
{
public string Name { get; set; } = string.Empty;
public string Code { get; set; } = string.Empty;
}would result
export interface CarDto {
name?: string;
code?: string;
}Which may seem reasonable as those two properties are not required from user to input so they are optional.
But when you think of it as a class thar represents an OUTPUT class not INPUT if it's an output class, having such line like this public string Name { get; set; } = string.Empty; means that the property name would definitely have value because of the initial value given. so the dto generated would be reasonable if it was
export interface CarDto {
name: string;
code: string;
}so client knows that it's 100% has value...
Suggested change is to introduce additional property in PropertyApiDescriptionModel as IsOptional maybe ? or modify on the IsRequired property... and use like the following
public static PropertyApiDescriptionModel Create(PropertyInfo propertyInfo, bool isOutput) this would have different treatment and isOutput would be different in treating IsOptional or in IsRequired and isOutput would be propagated from any function that would use it .. and isOutput would have default value as false to normally treat as Request/Input Dtos
TypeApiDescriptionModel, PropertyApiDescriptionModel etc.
if the given solution is accepted i would be happy to implement it in a PR.
Reproduction Steps
No response
Expected behavior
No response
Actual behavior
No response
Regression?
No response
Known Workarounds
Customize full cycle from PropertyApiDescriptionModel or highest level to the bottom to PropertyApiDescriptionModel
Version
10.6
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
No response
Source: abpframework/abp