-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include custom annotations in generated schemas / code #1618
Comments
This is in scope and would be a useful feature. We want to think carefully about how best to do this. See also #1830 I think using |
I think encoding the extra information in slots:
age:
minimum_value: 0 # this will generate `minimum: 0` in JSON Schema
annotations:
hidden: true
minimum: 10 # uh oh! |
Do we also have to worry about the scenario where a future version of json-schema introduces a keyword |
Following @pkalita-lbl approach, slots:
age:
minimum_value: 0 # this will generate `minimum: 0` in JSON Schema
annotations:
options:
hidden: true
minimum: 10 # uh oh! with {
"type": "object",
"properties": {
"age": {
"type": "int",
"minimum": 10
"options": {
"hidden": true
}
}
} with {
"type": "object",
"properties": {
"age": {
"type": "int",
"minimum": 0
"x-options": {
"hidden": true
},
"x-minimum": 10
}
} or even {
"type": "object",
"properties": {
"age": {
"type": "int",
"minimum": 0
"options": {
"hidden": true
},
"x-minimum": 10
}
} |
I agree. I just wanted to flag it as something we should be clear on and communicate to the user (through documentation, runtime warnings, etc) so that no one is surprised. |
I'd like to register my interest in this feature as well, in relation to the automatic generation of user interfaces from schemas (similar to @simontaurus's use case). I'm focusing specifically on SHACL. I've adapted
If anyone has some more insight to share about these challenges I'm facing, I would love to hear them! I'm happy to create a PR to address shaclgen improvements ito annotations, once the uncertainties are gone. Disclaimers:
|
This is for the SHACL generator in response to linkml#1618. Code is added to shaclgen.py to: - allow users to specify the --include-annotations tag if they want annotations (on classes, slots, and types) to be included in the exported SHACL shapes - determine the datatype of both annotation tag and value (a CURIE is identified by searching for the ':' character) - add the correct triples to the shacl output (to a nodeshape for classes, and to a property shape for slots and slots with typesas ranges)
…part of shacl shapes (#2111) * Add --include-annotations option for shaclgen This is for the SHACL generator in response to #1618. Code is added to shaclgen.py to: - allow users to specify the --include-annotations tag if they want annotations (on classes, slots, and types) to be included in the exported SHACL shapes - determine the datatype of both annotation tag and value (a CURIE is identified by searching for the ':' character) - add the correct triples to the shacl output (to a nodeshape for classes, and to a property shape for slots and slots with typesas ranges) * fix linting * Update snapshot data in 'test_scripts' after updating kitchen sink schema for shaclgen annotation tests * Update shaclgen.py Add a TODO comment --------- Co-authored-by: Chris Mungall <cjm@berkeleybop.org>
…part of shacl shapes (linkml#2111) * Add --include-annotations option for shaclgen This is for the SHACL generator in response to linkml#1618. Code is added to shaclgen.py to: - allow users to specify the --include-annotations tag if they want annotations (on classes, slots, and types) to be included in the exported SHACL shapes - determine the datatype of both annotation tag and value (a CURIE is identified by searching for the ':' character) - add the correct triples to the shacl output (to a nodeshape for classes, and to a property shape for slots and slots with typesas ranges) * fix linting * Update snapshot data in 'test_scripts' after updating kitchen sink schema for shaclgen annotation tests * Update shaclgen.py Add a TODO comment --------- Co-authored-by: Chris Mungall <cjm@berkeleybop.org>
* Implement equals_string and equals_string_in * Remove renaming§ * Add validation rules * Add validation for equals_string and equals_string_in in schema loader * Revert renaming * Remove obsolete code * Remove obsolete code * Fix codespell errors * Resolve flake errors * Reforamt files * Fix lint errors * fix lint errors * Add unit tests for equals_string and equals_string_in * Make quality checks happy (#2136) * Update poetry lockfile * hotwo on deprecation * `shaclgen`: Add `--include-annotations` option to let annotations be part of shacl shapes (#2111) * Add --include-annotations option for shaclgen This is for the SHACL generator in response to #1618. Code is added to shaclgen.py to: - allow users to specify the --include-annotations tag if they want annotations (on classes, slots, and types) to be included in the exported SHACL shapes - determine the datatype of both annotation tag and value (a CURIE is identified by searching for the ':' character) - add the correct triples to the shacl output (to a nodeshape for classes, and to a property shape for slots and slots with typesas ranges) * fix linting * Update snapshot data in 'test_scripts' after updating kitchen sink schema for shaclgen annotation tests * Update shaclgen.py Add a TODO comment --------- Co-authored-by: Chris Mungall <cjm@berkeleybop.org> * Erdiagram include upstream (#2139) * Include upstream classes into ERD diagram of selected entitites Add docs for —include-upstream * Fix unit test for Py3.9 * Update poetry lockfile * Implement equals_string and equals_string_in * Resolve flake errors * fix lint errors * Fix tests for equals_string_in feature Signed-off-by: Vincent Kelleher <vincent.kelleher@gaia-x.eu> * Fix gen shacl test * Fix unit tests * Reformat code * Fix missing type * Reformt * Fix lint errors * Fix lint errors * Fix unti tests * Format imports; ensure that tox and pre-commit agree on a ruff version --------- Signed-off-by: Vincent Kelleher <vincent.kelleher@gaia-x.eu> Co-authored-by: Anja Strunk <anja.strunk@cloudandheat.com> Co-authored-by: Vlad Korolev <vlad@v-lad.org> Co-authored-by: cmungall <50745+cmungall@users.noreply.github.com> Co-authored-by: Sierra Taylor Moxon <sierra.taylor@gmail.com> Co-authored-by: Stephan Heunis <s.heunis@fz-juelich.de> Co-authored-by: Chris Mungall <cjm@berkeleybop.org> Co-authored-by: Vincent Kelleher <vincent.kelleher@gaia-x.eu> Co-authored-by: anjastrunk <119566837+anjastrunk@users.noreply.github.com>
* Implement equals_string and equals_string_in * Remove renaming§ * Add validation rules * Add validation for equals_string and equals_string_in in schema loader * Revert renaming * Remove obsolete code * Remove obsolete code * Fix codespell errors * Resolve flake errors * Reforamt files * Fix lint errors * fix lint errors * Add unit tests for equals_string and equals_string_in * Make quality checks happy (linkml#2136) * Update poetry lockfile * hotwo on deprecation * `shaclgen`: Add `--include-annotations` option to let annotations be part of shacl shapes (linkml#2111) * Add --include-annotations option for shaclgen This is for the SHACL generator in response to linkml#1618. Code is added to shaclgen.py to: - allow users to specify the --include-annotations tag if they want annotations (on classes, slots, and types) to be included in the exported SHACL shapes - determine the datatype of both annotation tag and value (a CURIE is identified by searching for the ':' character) - add the correct triples to the shacl output (to a nodeshape for classes, and to a property shape for slots and slots with typesas ranges) * fix linting * Update snapshot data in 'test_scripts' after updating kitchen sink schema for shaclgen annotation tests * Update shaclgen.py Add a TODO comment --------- Co-authored-by: Chris Mungall <cjm@berkeleybop.org> * Erdiagram include upstream (linkml#2139) * Include upstream classes into ERD diagram of selected entitites Add docs for —include-upstream * Fix unit test for Py3.9 * Update poetry lockfile * Implement equals_string and equals_string_in * Resolve flake errors * fix lint errors * Fix tests for equals_string_in feature Signed-off-by: Vincent Kelleher <vincent.kelleher@gaia-x.eu> * Fix gen shacl test * Fix unit tests * Reformat code * Fix missing type * Reformt * Fix lint errors * Fix lint errors * Fix unti tests * Format imports; ensure that tox and pre-commit agree on a ruff version --------- Signed-off-by: Vincent Kelleher <vincent.kelleher@gaia-x.eu> Co-authored-by: Anja Strunk <anja.strunk@cloudandheat.com> Co-authored-by: Vlad Korolev <vlad@v-lad.org> Co-authored-by: cmungall <50745+cmungall@users.noreply.github.com> Co-authored-by: Sierra Taylor Moxon <sierra.taylor@gmail.com> Co-authored-by: Stephan Heunis <s.heunis@fz-juelich.de> Co-authored-by: Chris Mungall <cjm@berkeleybop.org> Co-authored-by: Vincent Kelleher <vincent.kelleher@gaia-x.eu> Co-authored-by: anjastrunk <119566837+anjastrunk@users.noreply.github.com>
saw this when searching for related issues for a PR. this is done for pydanticgen at least via the |
Is your feature request related to a problem? Please describe.
We are currently working on a link schema repo https://opensemantic.world/ combining json-schema and json-ld, similar to #474
On the way we recognized that linkml (great work!) already addresses a lot of problems we have identified, especially the bridges to OWL and SHACL.
However, since we focus both on programmatical and graphical interfaces would also need some custom annotations
for custom vocabular e. g. used by https://github.com/json-editor/json-editor to generate html forms.
Describe the solution you'd like
Option to transfer
range
even wheninlined_as_list: false
)hidden: true
for autogenerated fields in formsinto jsonschema and pydantic classes
Note: the extra parameter for Field() is also generated by https://github.com/koxudaxi/datamodel-code-generator
Maybe utilizing linkml
annotations
and dump the value as dict in the json-schema property and the pydantic Field if the generator was called with--include-annotations=True
would be a solution for b)How important is this feature? Select from the options below:
• Important - it's a blocker and can't do work without it (but of course I understand if this is out-of-scope)
When will use cases depending on this become relevant? Select from the options below:
• Mid-term - 2-4 months
Additional context
Related:
The text was updated successfully, but these errors were encountered: