Closed Nielsien closed 3 years ago
Oops commitlint was disabled, next commits will be following the commitlint convention
Okay so this is more of a work in progress not ready for merging. A few things:
You added some odd capitalisation on the schema name. I think the DGNSS part of both the schema and filename should be lower case like the rest of the repo. Similar casing issues on the enums. We shy away from capitals in filenames due to some operating systems having case-insensitive filesystems. Also changing case is not always seen as a change in git.
typo in ais-special-maneuvre.json -> ais-special-maneuver.json
The reason jest fails is because not all the enum types are exported in schemas.ts
. The schema validator imports them from there automatically so they need to be exported. I added the missing ais message type enum as a test and it then moved on to the next one thats missing. I recommend adding an ais
namespace inside the enum structure to mirror the folder structure you chose.
So something like this:
export const schemas = {
core: { ... },
enum: {
deviceType: enumDeviceType as JSONSchema7,
effortZone: enumEffortZone as JSONSchema7,
...
ais: {
altitudeSensorTypes: enumAISAltitudeSensorTypes as JSONSchema7,
shipTypes: enumAISShipTypes as JSONSchema7,
...
}
}
Sort them alphabetically to ensure you can easily see which is missing.
And finally for the switching json schema structure look at the entry_type
setup between the core/base-entry.json and the specialised schemas in the src/entry/
folder. The entry_type
is defined as a string in the base class and the specific types use an enum with only 1 option. This will allow for runtime validation to pick the right schema. You will end up with specialised schemas in separate files though.
Oh and disabling commitlint is a bannable offense ;)
Very well and thanks!
The odd capitalization was to indicate a abbreviation of an term like they do in the navigation center docs, but will change to lower case. I'll improve on those points, and make a worthwhile pr.
I'll close this pull request and create a new fork with commitlint.
Things I added:
At the moment an AIS measurement is just a big object with lots of optional properties you can add. The way I wanted it to work is that a certain message_type value binds certain required properties, but could not find a way to satisify this yet, will look to it in the coming weeks.
I want to write more tests for the ais, but need to find a way to bind required properties to a certain message_type value
Example schema code of how I wanted it to work:
But this code does not work with json schemas so need to find something. Maybe a way to do this is just to handle it in tests instead of json schemas. Or write a different schema for each message_type, but this would make a lot of duplicate properties in the total docs
Further my tests fail because it says:
'can't resolve reference https://poseidat.org/schema/enum/ais/ais-message-type.json'
But I think the reason is that jest cant find my schemas since they arent yet on the live version. So I think i cant test those until they are live