glideapps / glideapps/quicktype
Complex schema issues
- Dominant language
- TypeScript
- Stars
- 13.9k
- Forks
- 1.2k
- Avg merge
- 8h 53m
- Merged PRs (30d)
- 369
Description
Hi, I am working with a quite complex schema and I am having trouble with having all classes convert from JSON schema to C#.
The schema looks like the following snippet:
"Material": {
"patternProperties": {
"^.*\\S.*$": {
"type": "object",
"properties": {
"roughness": {
"type": "string",
"enum": [
"MediumRough",
"MediumSmooth",
"Rough",
"Smooth",
"VeryRough",
"VerySmooth"
]
},
"thickness": {
"type": "number",
"units": "m",
"minimum": 0.0,
"exclusiveMinimum": true,
"ip-units": "in"
},
"conductivity": {
"type": "number",
"units": "W/m-K",
"minimum": 0.0,
"exclusiveMinimum": true
},
"density": {
"type": "number",
"units": "kg/m3",
"minimum": 0.0,
"exclusiveMinimum": true
},
"specific_heat": {
"type": "number",
"units": "J/kg-K",
"minimum": 100.0
},
"thermal_absorptance": {
"type": "number",
"minimum": 0.0,
"exclusiveMinimum": true,
"default": 0.9,
"maximum": 0.99999
},
"solar_absorptance": {
"type": "number",
"default": 0.7,
"minimum": 0.0,
"maximum": 1.0
},
"visible_absorptance": {
"type": "number",
"minimum": 0.0,
"default": 0.7,
"maximum": 1.0
}
},
"required": [
"roughness",
"thickness",
"conductivity",
"density",
"specific_heat"
]
}
},
"name": {
"type": "string",
"is_required": true,
"reference": [
"MaterialName"
]
}
}
and the output from quicktype looks like:
[JsonProperty("Material", Required = Required.DisallowNull, NullValueHandling = NullValueHandling.Ignore)]
public Material Material { get; set; }
I was expecting something closer to:
public partial class Material
{
[JsonProperty("conductivity")]
public double Conductivity { get; set; }
[JsonProperty("density")]
public double Density { get; set; }
[JsonProperty("roughness")]
public RoughnessOfCollectorEnum Roughness { get; set; }
[JsonProperty("solar_absorptance", NullValueHandling = NullValueHandling.Ignore)]
public double? SolarAbsorptance { get; set; }
[JsonProperty("specific_heat")]
public double SpecificHeat { get; set; }
[JsonProperty("thermal_absorptance", NullValueHandling = NullValueHandling.Ignore)]
public double? ThermalAbsorptance { get; set; }
[JsonProperty("thickness")]
public double Thickness { get; set; }
[JsonProperty("visible_absorptance", NullValueHandling = NullValueHandling.Ignore)]
public double? VisibleAbsorptance { get; set; }
}
I would appreciate any pointers that could help me with this conversion.
I am attaching the full schema here:
[Energy+.schema.zip](https://github.com/quicktype/quicktype/files/7736911/Energy%2B.schema.zip)
An older version of the schema converted nicely with quicktype. I am also adding that here.
[Energy+.schema_old.zip](https://github.com/quicktype/quicktype/files/7737393/Energy%2B.schema_old.zip)
Contributor guide
Assessment
This issue has not been assessed yet.