Record vs RecordSet
See original GitHub issueBoth BeerXML 1.0 and the preliminary BeerXML 2.0.1 make a difference between a Record and a RecordSet.
I don’t quite understand the json schema files, but, by looking at the examples in the test directory, I get the impression that everything is treated as a RecordSet in beerjson. Many filenames seem to indicate a single record but they include the plural mentioning the type of record, followed by a list object (although with a single element defining the specific record). Am I reading it wrong or is it really what you want?
For example, instead of the file HopWithRequiredFieldsOnly.json
reading
"beer_xml": {
"version": 2.01,
"hop_varieties": [
{
"name": "Cascade",
"origin": "US",
"alpha_acid_units": 5.5
}
]
}
}
couldn’t it read
"beer_xml": {
"version": 2.01,
"hop": {
"name": "Cascade",
"origin": "US",
"alpha_acid_units": 5.5
}
}
}
Is this allowed?
If not, although it would require more work, wouldn’t it be better to have a json-schema for single records and make the json-schema for record sets to have a list referencing the schema for a single record?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
Well, it is possible to make experiments in tests and check it. By default constructions without array will fail validation. We could rewrite root schema in this way:
to archive validation for arrays and single objects. But I can’t understand key reason for it. Brewing software can handle arrays, single objects and arrays with one item without any troubles.
I managed to install the latest Node.js, which already comes with npm, and was able to locally run
npm test
. Pretty cool. I played a little bit with it, purposely making some erros to see how it goes. But I still need to understand the syntax of json schema to be able to modify it without making a mess. For instance, I tried to adapt in hops.json the modification above that @krutilin suggested on recipes.json to work with either an object or an array but I failed.Anyway, if I succeed in understanding json-schema, then I might try addressing some of the issues, instead of only making remarks.
I will be following https://spacetelescope.github.io/understanding-json-schema/index.html to learn more about json schemas. It looks nice.