oleksa
6 years agoNew Contributor
"readOnly" and "required" C# properties generation
Dears
Please help me with readOnly property generation
I've found that properties declared with readOnly -oneOf are generated with Object data type.
Customer: type: object required: - "ClientTypeId" properties: ClientTypeId: type: "integer" format: "int32" ClientType: readOnly: true allOf: - $ref: '#/definitions/ClientType'
definitions:
ClientType:
type: object
required:
- "ClientTypeId"
properties:
ClientTypeId:
type: "integer"
format: "int32"
Description:
type: "string"
LegalType:
type: "boolean"
ClientType is generated as
/// <summary> /// Gets or Sets ClientType /// </summary> [DataMember(Name="ClientType")] public Object ClientType { get; set; }
however I expected that it will get strongly typed property ClientType according to the definition
additionally ClientTypeId is generated as Nullable<int> property but I expect that it will be generated like int ClientTypeId:
/// <summary> /// Gets or Sets ClientTypeId /// </summary> [Required] [DataMember(Name="ClientTypeId")] public int? ClientTypeId { get; set; }
I used both online generator https://generator.swagger.io/api/gen/servers/aspnetcore and offline swagger-codegen (https://github.com/swagger-api/swagger-codegen) at master.
Is it possible to get ClientType to be generated as
public ClientType ClientType { get; set; }
?
Regards