openkfw / open-geodata-model

Open Geodata Model for Mapping Project Sites in ODA
https://openkfw.github.io/open-geodata-model/
Other
4 stars 8 forks source link

Create a json schema for the model #79

Closed fretchen closed 2 months ago

fretchen commented 3 months ago

This is a Work In Progress to establish a basic json schema reference for the model and hence to fix #76 . At the time of writing the draft it does:

Some obvious open issues arise from the documentation, which is quite poor for the moment.

I also think that we need to fix #77 before we can consider this one.

fretchen commented 3 months ago

This is now the first full pull request, which esablishes a machine-readable reference for the project location model. It should therefore fix #76. It contains:

To document the increasing number of technical tools, I also had to do some work on the structure of the documentation. You can see the updated documentation in my private repo.

I am looking forward to your comments. But if we succeed in merging this one, I am fairly optimistic that it could enable us to have a variety of converters and validators with fairly minimal effort.

goergen95 commented 3 months ago

Just a few comments that came to mind by quickly skimming through the JSON Schema:

fretchen commented 3 months ago

Let me go through the different points step-by-step

  1. budgetShare

This must be a value in € according to the technical notes. So it cannot be bounded from above, but I added a bound from below, which I tested.

  1. kcThemeSubSector, dac5PurposeCode

I see your point, but I am a tiny bit hesitent to add all the enums. These are a lot of enums, making the schema (and hence its documentation) quite lengthy. I am wondering a bit if it would not be better to put those things into code that would be part of an validator. I somehow expect that we will have to write excel and csv validators anyways and we have to handle the translations etc. So I am a bit torn between the options here. Might be a point to be solved before a release 1.1, but ok to separate out from this PR ?

  1. geographicExactnessand locationActivityStatus

This is well noted, but even a larger problem as we will have even more labels from different translations. So I guess that we will have to require those values to part of a code list and only show the "labels" in the different templates? This would go in a similiar direction as we started for the locationType where each type has several attributes (including translations). Might be another point to be solved before a release 1.1, but ok to separate out from this PR ?

  1. locationTypeName

I am fairly sure that the suggested validation is beyond the capabilities of jsonschema and will require a specific validator behind. I am completely sure that I do not know how to implement this with jsonschema alone.

  1. uniqueId

Good question. I would guess that this an open question for the moment. @Jo-Schie ?

Taken together, I feels that jsonschema is a first step, but that it will certainly have to be integrated into custom validators...

goergen95 commented 3 months ago

Thanks!

I guess I just got confused by the name budgetShare. To me this sounds like a percentage. Maybe one could think of a better name if it is not really a share.

There are different ways to compose complex schema, one of which is the $ref keyword with which you can compose the main schema from different sub-schemas. This has the benefit that each individual schema remains understandable and maintainable.

I am indifferent wether or not to include this (and also possible issues arising from translation) in the current PR. But handling the complexity of the specification in separate implementations of several validators is a very bad idea as it introduces a very large surface of failure for something JSON Schema is specifically designed to solve.

fretchen commented 3 months ago

Sounds good to me. Depending on the input of @Jo-Schie I would tend to separate the issue with the translations and the complex schemes. I agree with the schemes and the $ref as you suggested. It would however possibly involve some automatic creation from the official references. So would have to see how this would work out best...

Jo-Schie commented 2 months ago

i merged this for now. I think it is good to have a starting point for dicussions. Thansk @fretchen !!