mdmodels-core 0.2.10__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/.github/workflows/test.yml +10 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/Cargo.lock +1 -1
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/Cargo.toml +1 -1
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/PKG-INFO +1 -1
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/exporters/schemas.md +7 -7
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/syntax/best_practices.md +1 -1
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/syntax/objects.md +2 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/syntax/preambles.md +10 -2
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/syntax/semantics.md +40 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/pyproject.toml +1 -1
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/attribute.rs +148 -14
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/bin/cli.rs +3 -3
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/datamodel.rs +7 -3
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/exporters.rs +483 -6
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/json/export.rs +14 -8
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/json/import.rs +6 -4
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/json/schema.rs +1 -3
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/jsonld/export.rs +170 -23
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/linkml/import.rs +1 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/markdown/frontmatter.rs +85 -16
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/markdown/parser.rs +2 -3
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/markdown/position.rs +3 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/object.rs +42 -2
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/option.rs +38 -2
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/pipeline.rs +1 -1
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/owl.jinja +23 -19
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/python-dataclass.jinja +19 -10
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/python-macros.jinja +26 -2
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/python-pydantic.jinja +72 -15
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/rust.jinja +32 -25
- mdmodels_core-0.3.0/templates/shacl.jinja +81 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/shex.jinja +3 -3
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_internal_schema.json +1 -1
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_meta_json_schema.json +2 -1
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_owl.ttl +5 -5
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_pydantic.py +82 -16
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_pydantic_unitdef.py +62 -10
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_python_dc.py +14 -8
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_python_pydantic_xml.py +2 -2
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_rust.rs +1 -1
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_rust_ld.rs +13 -13
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_shacl.ttl +16 -23
- mdmodels_core-0.3.0/tests/data/model_jsonld.md +56 -0
- mdmodels_core-0.3.0/tests/envs/python/.gitignore +3 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/python/Dockerfile +1 -1
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/python/requirements.txt +3 -1
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/python/test_pydantic.py +4 -5
- mdmodels_core-0.3.0/tests/envs/python/test_pydantic_jsonld.py +169 -0
- mdmodels_core-0.3.0/tests/envs/python/test_shacl.py +75 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/integration_tests.rs +27 -6
- mdmodels_core-0.2.10/templates/shacl.jinja +0 -50
- mdmodels_core-0.2.10/tests/data/expected_context.jsonld +0 -21
- mdmodels_core-0.2.10/tests/envs/python/.gitignore +0 -1
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/.github/scripts/generate_types.sh +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/.github/workflows/assets.yml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/.github/workflows/docs.yml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/.github/workflows/format.yml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/.github/workflows/lint.yml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/.github/workflows/npm_bundler.yml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/.github/workflows/npm_web.yml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/.github/workflows/publish.yml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/.github/workflows/publish_pypi.yml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/.github/workflows/publish_test_pypi.yml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/.gitignore +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/.pre-commit-config.yaml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/LICENSE.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/README.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/build.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/.gitignore +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/book.toml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/SUMMARY.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/cli/cli.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/cli/generation.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/cli/llm.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/cli/pipelines.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/cli/schema_validation.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/examples/database_models.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/examples/examples.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/examples/hello_md_models.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/examples/union_types.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/exporters/apis.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/exporters/documentation.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/exporters/exporters.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/exporters/languages.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/faq/faq.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/faq/validation.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/introduction.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/quickstart.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/syntax/descriptions.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/syntax/enums.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/syntax/full_example.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/syntax/property_options.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/src/syntax/syntax.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/types/equation.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/docs/types/unit-definition.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/bindings/python.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/bindings/wasm.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/error.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/git.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/json/validation.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/jsonld/schema.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/lib.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/linkml/export.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/linkml/schema.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/llm/extraction.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/llm/input.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/tree.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/validation.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/src/xmltype.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/golang.jinja +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/graphql.jinja +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/julia.jinja +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/markdown-compact.jinja +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/markdown.jinja +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/mermaid.jinja +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/mkdocs.jinja +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/protobuf.jinja +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/python-pydantic-xml.jinja +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/typescript-zod.jinja +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/typescript.jinja +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/templates/xml-schema.jinja +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_golang.go +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_golang_gorm.go +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_graphql.graphql +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_internal_full_schema.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_internal_schema_inheritance.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_invalid_complete.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_json_schema.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_json_schema_openai.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_julia.jl +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_linkml.yml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_mermaid.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_mkdocs.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_proto.proto +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_protobuf.proto +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_rust_forbidden.rs +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_shex.shex +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_typescript.ts +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_typescript_zod.ts +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_typescript_zod_json_ld.ts +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/expected_xml_schema.xsd +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/invalid_dataset.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_compact.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_dashed_names.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_duplicates.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_forbidden_names.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_full_documentation.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_golang_gorm.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_inheritance.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_inheritance_invalid.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_invalid_complete.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_invalid_names.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_invalid_xml_option.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_invalid_xml_wrapped.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_json_schema.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_json_schema_openai.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_json_validation.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_merge.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_merge_invalid.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_meta.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_missing_types.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_multiple_keyword.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_multiple_types.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_multiple_types_invalid.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_no_frontmatter.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_no_objects.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_options.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_owl.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_unitdef.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/model_w_html.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/old_schema.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/precice_topology_schema.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/data/valid_dataset.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/go/Dockerfile +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/go/generated.go +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/go/generated_test.go +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/go/go.mod +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/julia/test.jl +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/python/test_dataclasses.py +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/python/test_pydantic_xml.py +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/typescript/.gitignore +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/typescript/Dockerfile +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/typescript/package-lock.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/typescript/package.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/typescript/test.ts +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/envs/typescript/tsconfig.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/test_pipeline.toml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/test_pipeline_per_spec.toml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/tests/test_pipeline_per_spec_invalid.toml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/types/README.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/types/equation/equation-internal.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/types/equation/equation.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/types/equation/equation.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/types/equation/equation.xsd +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/types/equation/gen.toml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/types/unit-definition/gen.toml +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/types/unit-definition/unit-definition-internal.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/types/unit-definition/unit-definition.json +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/types/unit-definition/unit-definition.md +0 -0
- {mdmodels_core-0.2.10 → mdmodels_core-0.3.0}/types/unit-definition/unit-definition.xsd +0 -0
|
@@ -97,6 +97,16 @@ jobs:
|
|
|
97
97
|
-o tests/envs/python/gen_pydantic_xml.py \
|
|
98
98
|
-t python-pydantic-xml
|
|
99
99
|
|
|
100
|
+
cargo run convert \
|
|
101
|
+
-i tests/data/model_jsonld.md \
|
|
102
|
+
-o tests/envs/python/gen_pydantic_jsonld.py \
|
|
103
|
+
-t python-pydantic
|
|
104
|
+
|
|
105
|
+
cargo run convert \
|
|
106
|
+
-i tests/data/model_jsonld.md \
|
|
107
|
+
-o tests/envs/python/gen_shapes.ttl \
|
|
108
|
+
-t shacl
|
|
109
|
+
|
|
100
110
|
- name: Build Docker image
|
|
101
111
|
run: docker build -t pythontests -f tests/envs/python/Dockerfile .
|
|
102
112
|
- name: Run tests
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "mdmodels"
|
|
3
3
|
authors = ["Jan Range <jan.range@simtech.uni-stuttgart.de>"]
|
|
4
4
|
description = "A tool to generate models, code and schemas from markdown files"
|
|
5
|
-
version = "0.
|
|
5
|
+
version = "0.3.0"
|
|
6
6
|
edition = "2021"
|
|
7
7
|
license = "MIT"
|
|
8
8
|
repository = "https://github.com/FAIRChemistry/md-models"
|
|
@@ -120,17 +120,17 @@ md-models convert -i model.md -t shacl -o shapes.ttl
|
|
|
120
120
|
|
|
121
121
|
**Features:**
|
|
122
122
|
|
|
123
|
-
- Generates SHACL
|
|
124
|
-
-
|
|
125
|
-
-
|
|
123
|
+
- Generates a SHACL NodeShape for every object type
|
|
124
|
+
- One property shape and one path per property, using the property's term or `<Object>:<field>`
|
|
125
|
+
- Arrays are validated as ordered RDF lists (list paths ending in `rdf:first`); a required array needs at least one item
|
|
126
|
+
- Cardinality constraints (sh:minCount, sh:maxCount; no maximum on lists or shared terms)
|
|
127
|
+
- Datatype constraints matching what the JSON-LD context produces (`float` and `number` accept `xsd:integer` or `xsd:double`, since JSON-LD types whole numbers as integers; `bytes` is a plain `xsd:string`)
|
|
128
|
+
- `IRI` fields require `sh:nodeKind sh:IRI`
|
|
126
129
|
- Enumeration constraints (sh:in)
|
|
127
|
-
- Class constraints (sh:class)
|
|
128
|
-
- Term-based property paths (supports semantic annotations)
|
|
129
130
|
- Class-scoped prefixes for semantic web integration
|
|
130
131
|
|
|
131
132
|
**Requirements:**
|
|
132
133
|
|
|
133
|
-
- Objects must have semantic terms defined (via `@term` annotations)
|
|
134
134
|
- The model must include ontology prefixes for proper RDF namespace handling
|
|
135
135
|
|
|
136
136
|
**Use Cases:**
|
|
@@ -206,7 +206,7 @@ md-models convert -i model.md -t owl -o ontology.ttl
|
|
|
206
206
|
|
|
207
207
|
- Generates OWL 2 ontology definitions
|
|
208
208
|
- Class definitions with rdfs:comment descriptions
|
|
209
|
-
- Object properties for relationships between classes
|
|
209
|
+
- Object properties for relationships between classes, for arrays and for `IRI` fields (without `rdfs:range`)
|
|
210
210
|
- Datatype properties for primitive attributes
|
|
211
211
|
- Enumeration classes for enum types
|
|
212
212
|
- Subclass relationships (rdfs:subClassOf)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Best practices
|
|
2
2
|
|
|
3
3
|
1. **Use Descriptive Names**
|
|
4
|
-
- Object names should be PascalCase (e.g., `ResearchPublication`)
|
|
4
|
+
- Object names should be PascalCase (e.g., `ResearchPublication`). Names with spaces, `_` or `-` are joined with each word capitalized (`research publication` → `ResearchPublication`); existing capitals and acronyms are kept (`HTTPRequest` stays `HTTPRequest`)
|
|
5
5
|
- Attribute names should be in snake_case (e.g., `publication_year`)
|
|
6
6
|
- Use clear, domain-specific terminology
|
|
7
7
|
|
|
@@ -55,6 +55,8 @@ The data type of a property is very important and generally communicates what ki
|
|
|
55
55
|
- `float` - A floating point number
|
|
56
56
|
- `number` - A numeric value (integer or float)
|
|
57
57
|
- `boolean` - A true or false value
|
|
58
|
+
- `Identifier` - A local key, unique within a document and used for cross-references. Generated as a string; serialized as a plain literal in JSON-LD.
|
|
59
|
+
- `IRI` - A string that holds an IRI (e.g. a DOI or ontology URL). JSON-LD contexts coerce it to a node reference (`"@type": "@id"`), and JSON Schema adds `format: iri` to single-valued `IRI` fields.
|
|
58
60
|
|
|
59
61
|
### Arrays
|
|
60
62
|
|
|
@@ -6,7 +6,7 @@ The preamble is the first section of your data model. It is used to provide meta
|
|
|
6
6
|
---
|
|
7
7
|
id: my-data-model
|
|
8
8
|
prefix: md
|
|
9
|
-
repo:
|
|
9
|
+
repo: https://github.com/myorg/myrepo/
|
|
10
10
|
prefixes:
|
|
11
11
|
schema: http://schema.org/
|
|
12
12
|
nsmap:
|
|
@@ -36,6 +36,14 @@ The frontmatter section of your MD-Models document supports several configuratio
|
|
|
36
36
|
schema: http://schema.org/
|
|
37
37
|
foaf: http://xmlns.com/foaf/0.1/
|
|
38
38
|
```
|
|
39
|
+
- **Note**: IRIs are used exactly as written. End each IRI with the character that should
|
|
40
|
+
precede the local name, e.g. `schema: https://schema.org/`, `rdfs: http://www.w3.org/2000/01/rdf-schema#`
|
|
41
|
+
or `item: https://example.org/item_` (so `item:42` expands to
|
|
42
|
+
`https://example.org/item_42`, a style some ontologies use). Prefixes whose IRI does not end in
|
|
43
|
+
`: / ? # [ ] @` are emitted with `"@prefix": true` in JSON-LD contexts. When a prefix
|
|
44
|
+
IRI ends in a letter or digit (e.g. `schema: https://schema.org`), md-models prints a
|
|
45
|
+
warning while generating JSON-LD, SHACL, OWL, ShEx and the Python/Rust models, because
|
|
46
|
+
`schema:name` would expand to `https://schema.orgname`.
|
|
39
47
|
|
|
40
48
|
### `nsmap`
|
|
41
49
|
|
|
@@ -51,7 +59,7 @@ The frontmatter section of your MD-Models document supports several configuratio
|
|
|
51
59
|
### `repo`
|
|
52
60
|
|
|
53
61
|
- **Type**: String
|
|
54
|
-
- **Default**: `
|
|
62
|
+
- **Default**: `https://example.org/<prefix>/` (a reserved placeholder domain; set your own namespace, a warning is printed when a semantic format is generated from the placeholder)
|
|
55
63
|
- **Description**: Specifies the base repository URL for your model. This can be used to generate absolute URIs for your model elements.
|
|
56
64
|
- **Example**: `repo: https://github.com/myorg/myrepo/`
|
|
57
65
|
|
|
@@ -66,3 +66,43 @@ Once these annotations are defined, they are automatically added to the generate
|
|
|
66
66
|
- `typescript` (JSON-LD)
|
|
67
67
|
- `shacl` (Shapes Constraint Language)
|
|
68
68
|
- `shex` (Shape Expressions)
|
|
69
|
+
|
|
70
|
+
## Identifiers, IRIs and JSON-LD
|
|
71
|
+
|
|
72
|
+
An `Identifier` is a **local key**: it names an object within the document (for example
|
|
73
|
+
`id: "p1"` on a `Product`) and other fields use it to point at that object
|
|
74
|
+
(`product_id: "p1"` on an `Order`). In JSON-LD it is always a literal, never an IRI.
|
|
75
|
+
|
|
76
|
+
Global identity (an entry in an external database, an ontology term, a DOI) is expressed
|
|
77
|
+
either as an `@type` of the object or with a field of type `IRI`, which JSON-LD treats as
|
|
78
|
+
a link:
|
|
79
|
+
|
|
80
|
+
```markdown
|
|
81
|
+
### Product
|
|
82
|
+
|
|
83
|
+
- **id**
|
|
84
|
+
- Type: Identifier
|
|
85
|
+
- homepage
|
|
86
|
+
- Type: IRI
|
|
87
|
+
- Term: schema:url
|
|
88
|
+
- references
|
|
89
|
+
- Type: IRI[]
|
|
90
|
+
- Term: schema:citation
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Fields without a `Term` are still part of the JSON-LD graph: they map to
|
|
94
|
+
`<prefix>:<Object>/<field>` (for example `ex:Product/id`), the same IRI the OWL and
|
|
95
|
+
SHACL exports use.
|
|
96
|
+
|
|
97
|
+
### Arrays
|
|
98
|
+
|
|
99
|
+
Every array (`string[]`, `Product[]`, `IRI[]`, ...) is an ordered RDF list: the JSON-LD
|
|
100
|
+
context declares `"@container": "@list"`, so order and duplicates survive a round trip.
|
|
101
|
+
In SPARQL, reach the items with the property path `?s <prop>/rdf:rest*/rdf:first ?item`.
|
|
102
|
+
Dates are typed `xsd:date`.
|
|
103
|
+
|
|
104
|
+
- **SHACL** validates the list items through the same path; a required array means at least one item.
|
|
105
|
+
- **OWL** declares array properties as `owl:ObjectProperty` without an `rdfs:range`
|
|
106
|
+
(a range would type the list node, not its items); the item type is named in the comment.
|
|
107
|
+
`IRI` fields are links and are object properties as well.
|
|
108
|
+
- **ShEx** shapes do not understand lists yet.
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
|
|
24
24
|
use crate::{
|
|
25
25
|
markdown::{parser::OptionKey, position::Position},
|
|
26
|
-
|
|
26
|
+
object::type_name,
|
|
27
|
+
option::{strip_quotes, AttrOption, RawOption},
|
|
27
28
|
validation::BASIC_TYPES,
|
|
28
29
|
xmltype::XMLType,
|
|
29
30
|
};
|
|
30
|
-
use convert_case::{Case, Casing};
|
|
31
31
|
use serde::{de::Visitor, Deserialize, Serialize};
|
|
32
32
|
use std::{error::Error, fmt, str::FromStr};
|
|
33
33
|
|
|
@@ -50,6 +50,9 @@ pub struct Attribute {
|
|
|
50
50
|
pub is_array: bool,
|
|
51
51
|
/// Is an identifier or not
|
|
52
52
|
pub is_id: bool,
|
|
53
|
+
/// Holds an IRI; JSON-LD contexts coerce it with `"@type": "@id"`
|
|
54
|
+
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
|
55
|
+
pub is_iri: bool,
|
|
53
56
|
/// Data types associated with the attribute.
|
|
54
57
|
pub dtypes: Vec<String>,
|
|
55
58
|
/// Documentation string for the attribute.
|
|
@@ -90,6 +93,7 @@ impl Attribute {
|
|
|
90
93
|
options: Vec::new(),
|
|
91
94
|
is_array: false,
|
|
92
95
|
is_id: false,
|
|
96
|
+
is_iri: false,
|
|
93
97
|
term: None,
|
|
94
98
|
required,
|
|
95
99
|
xml: Some(XMLType::from_str(name.as_str()).unwrap()),
|
|
@@ -128,7 +132,7 @@ impl Attribute {
|
|
|
128
132
|
OptionKey::Type => self.set_dtype(option.value)?,
|
|
129
133
|
OptionKey::Term => self.term = Some(option.value),
|
|
130
134
|
OptionKey::Description => self.docstring = option.value,
|
|
131
|
-
OptionKey::Default => self.default = Some(
|
|
135
|
+
OptionKey::Default => self.default = Some(self.parse_default(&option.value)?),
|
|
132
136
|
OptionKey::Multiple => self.is_array = option.value.to_lowercase() == "true",
|
|
133
137
|
OptionKey::Other => self.options.push(option.try_into()?),
|
|
134
138
|
OptionKey::Xml => {
|
|
@@ -139,6 +143,18 @@ impl Attribute {
|
|
|
139
143
|
Ok(())
|
|
140
144
|
}
|
|
141
145
|
|
|
146
|
+
/// Parses a default value, honouring the declared type: an unquoted literal on a
|
|
147
|
+
/// string-only attribute (e.g. `Default: 2.0` with `Type: string`) stays a string.
|
|
148
|
+
// ponytail: relies on `Type` being declared before `Default`; otherwise literal parsing applies
|
|
149
|
+
fn parse_default(&self, value: &str) -> Result<DataType, String> {
|
|
150
|
+
let parsed = DataType::from_str(value)?;
|
|
151
|
+
let string_only = !self.dtypes.is_empty() && self.dtypes.iter().all(|d| d == "string");
|
|
152
|
+
if string_only && !parsed.is_string() {
|
|
153
|
+
return Ok(DataType::String(value.trim().to_string()));
|
|
154
|
+
}
|
|
155
|
+
Ok(parsed)
|
|
156
|
+
}
|
|
157
|
+
|
|
142
158
|
/// Sets the data type for the attribute.
|
|
143
159
|
///
|
|
144
160
|
/// # Arguments
|
|
@@ -155,6 +171,10 @@ impl Attribute {
|
|
|
155
171
|
dtype = dtype.trim().to_string();
|
|
156
172
|
if self.is_identifier(&dtype) {
|
|
157
173
|
dtype = self.process_identifier(&dtype).to_string();
|
|
174
|
+
} else if dtype.trim_end_matches("[]").eq_ignore_ascii_case("iri") {
|
|
175
|
+
// IRI-valued field: generated as a string, coerced to an IRI in JSON-LD
|
|
176
|
+
self.is_iri = true;
|
|
177
|
+
dtype = format!("string{}", &dtype[3..]);
|
|
158
178
|
}
|
|
159
179
|
|
|
160
180
|
if let Some((prefix, name)) = dtype.split_once('.') {
|
|
@@ -168,7 +188,7 @@ impl Attribute {
|
|
|
168
188
|
}
|
|
169
189
|
|
|
170
190
|
if !BASIC_TYPES.contains(&dtype.as_str()) {
|
|
171
|
-
dtype = dtype
|
|
191
|
+
dtype = type_name(&dtype);
|
|
172
192
|
}
|
|
173
193
|
|
|
174
194
|
new_dtypes.push(dtype);
|
|
@@ -350,19 +370,32 @@ impl PartialEq for DataType {
|
|
|
350
370
|
impl FromStr for DataType {
|
|
351
371
|
type Err = String;
|
|
352
372
|
|
|
353
|
-
///
|
|
373
|
+
/// Parses a default value literal. A quoted value is always a string and is kept
|
|
374
|
+
/// verbatim (without the quotes); unquoted values are parsed as boolean, integer,
|
|
375
|
+
/// float or string, in that order.
|
|
354
376
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
355
|
-
let
|
|
356
|
-
|
|
377
|
+
let s = s.trim();
|
|
378
|
+
|
|
379
|
+
if let Some(inner) = strip_quotes(s) {
|
|
380
|
+
return Ok(DataType::String(inner.to_string()));
|
|
381
|
+
}
|
|
357
382
|
|
|
358
|
-
if
|
|
359
|
-
Ok(DataType::Boolean(
|
|
360
|
-
} else if
|
|
383
|
+
if s.eq_ignore_ascii_case("true") {
|
|
384
|
+
Ok(DataType::Boolean(true))
|
|
385
|
+
} else if s.eq_ignore_ascii_case("false") {
|
|
386
|
+
Ok(DataType::Boolean(false))
|
|
387
|
+
} else if let Ok(i) = s.parse::<i64>() {
|
|
361
388
|
Ok(DataType::Integer(i))
|
|
362
|
-
} else if let
|
|
389
|
+
} else if let Some(f) = s
|
|
390
|
+
.parse::<f64>()
|
|
391
|
+
.ok()
|
|
392
|
+
.filter(|f| f.is_finite() && s.bytes().any(|b| b.is_ascii_digit()))
|
|
393
|
+
{
|
|
394
|
+
// The digit check keeps words such as "nan" or "inf" as strings, and the
|
|
395
|
+
// finiteness check keeps overflowing literals such as "1e999" as strings
|
|
363
396
|
Ok(DataType::Float(f))
|
|
364
|
-
} else if !
|
|
365
|
-
Ok(DataType::String(
|
|
397
|
+
} else if !s.is_empty() {
|
|
398
|
+
Ok(DataType::String(s.to_string()))
|
|
366
399
|
} else {
|
|
367
400
|
Err("Invalid data type".to_string())
|
|
368
401
|
}
|
|
@@ -717,7 +750,78 @@ mod tests {
|
|
|
717
750
|
#[test]
|
|
718
751
|
fn from_str_parses_string() {
|
|
719
752
|
let dt = DataType::from_str("hello").unwrap();
|
|
720
|
-
assert_eq!(dt, DataType::String("
|
|
753
|
+
assert_eq!(dt, DataType::String("hello".to_string()));
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
#[test]
|
|
757
|
+
fn from_str_keeps_quoted_values_verbatim() {
|
|
758
|
+
for (raw, expected) in [
|
|
759
|
+
("\"2.0\"", "2.0"),
|
|
760
|
+
("\"1.10\"", "1.10"),
|
|
761
|
+
("\"007\"", "007"),
|
|
762
|
+
("\"true\"", "true"),
|
|
763
|
+
("\"\"", ""),
|
|
764
|
+
] {
|
|
765
|
+
assert_eq!(
|
|
766
|
+
DataType::from_str(raw).unwrap(),
|
|
767
|
+
DataType::String(expected.to_string()),
|
|
768
|
+
"{raw}"
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
#[test]
|
|
774
|
+
fn from_str_keeps_non_finite_floats_as_strings() {
|
|
775
|
+
assert_eq!(
|
|
776
|
+
DataType::from_str("1e999").unwrap(),
|
|
777
|
+
DataType::String("1e999".to_string())
|
|
778
|
+
);
|
|
779
|
+
assert_eq!(
|
|
780
|
+
DataType::from_str("-1e999").unwrap(),
|
|
781
|
+
DataType::String("-1e999".to_string())
|
|
782
|
+
);
|
|
783
|
+
assert_eq!(DataType::from_str("1e10").unwrap(), DataType::Float(1e10));
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
#[test]
|
|
787
|
+
fn from_str_parses_unquoted_literals() {
|
|
788
|
+
assert_eq!(DataType::from_str("True").unwrap(), DataType::Boolean(true));
|
|
789
|
+
assert_eq!(
|
|
790
|
+
DataType::from_str("FALSE").unwrap(),
|
|
791
|
+
DataType::Boolean(false)
|
|
792
|
+
);
|
|
793
|
+
assert_eq!(
|
|
794
|
+
DataType::from_str("Hello").unwrap(),
|
|
795
|
+
DataType::String("Hello".to_string())
|
|
796
|
+
);
|
|
797
|
+
assert_eq!(
|
|
798
|
+
DataType::from_str("nan").unwrap(),
|
|
799
|
+
DataType::String("nan".to_string())
|
|
800
|
+
);
|
|
801
|
+
assert_eq!(
|
|
802
|
+
DataType::from_str("inf").unwrap(),
|
|
803
|
+
DataType::String("inf".to_string())
|
|
804
|
+
);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
#[test]
|
|
808
|
+
fn default_follows_declared_string_type() {
|
|
809
|
+
let mut attr = Attribute::new("version".to_string(), false);
|
|
810
|
+
attr.add_option(RawOption::new("type".to_string(), "string".to_string()))
|
|
811
|
+
.unwrap();
|
|
812
|
+
attr.add_option(RawOption::new("default".to_string(), "2.0".to_string()))
|
|
813
|
+
.unwrap();
|
|
814
|
+
assert_eq!(attr.default, Some(DataType::String("2.0".to_string())));
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
#[test]
|
|
818
|
+
fn default_on_numeric_type_stays_numeric() {
|
|
819
|
+
let mut attr = Attribute::new("volume".to_string(), false);
|
|
820
|
+
attr.add_option(RawOption::new("type".to_string(), "float".to_string()))
|
|
821
|
+
.unwrap();
|
|
822
|
+
attr.add_option(RawOption::new("default".to_string(), "2.0".to_string()))
|
|
823
|
+
.unwrap();
|
|
824
|
+
assert_eq!(attr.default, Some(DataType::Float(2.0)));
|
|
721
825
|
}
|
|
722
826
|
|
|
723
827
|
#[test]
|
|
@@ -725,4 +829,34 @@ mod tests {
|
|
|
725
829
|
let dt = DataType::from_str("");
|
|
726
830
|
assert!(dt.is_err());
|
|
727
831
|
}
|
|
832
|
+
|
|
833
|
+
#[test]
|
|
834
|
+
fn test_iri_type_is_a_flagged_string() {
|
|
835
|
+
let mut attr = Attribute::new("homepage".to_string(), false);
|
|
836
|
+
attr.add_option(RawOption::new("type".to_string(), "IRI".to_string()))
|
|
837
|
+
.expect("Failed to add option");
|
|
838
|
+
assert_eq!(attr.dtypes, vec!["string".to_string()]);
|
|
839
|
+
assert!(attr.is_iri);
|
|
840
|
+
assert!(!attr.is_id);
|
|
841
|
+
assert!(!attr.is_array);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
#[test]
|
|
845
|
+
fn test_iri_array_type() {
|
|
846
|
+
let mut attr = Attribute::new("references".to_string(), false);
|
|
847
|
+
attr.add_option(RawOption::new("type".to_string(), "IRI[]".to_string()))
|
|
848
|
+
.expect("Failed to add option");
|
|
849
|
+
assert_eq!(attr.dtypes, vec!["string".to_string()]);
|
|
850
|
+
assert!(attr.is_iri);
|
|
851
|
+
assert!(attr.is_array);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
#[test]
|
|
855
|
+
fn test_identifier_is_not_an_iri() {
|
|
856
|
+
let mut attr = Attribute::new("id".to_string(), true);
|
|
857
|
+
attr.add_option(RawOption::new("type".to_string(), "Identifier".to_string()))
|
|
858
|
+
.expect("Failed to add option");
|
|
859
|
+
assert!(attr.is_id);
|
|
860
|
+
assert!(!attr.is_iri);
|
|
861
|
+
}
|
|
728
862
|
}
|
|
@@ -46,7 +46,7 @@ use std::{
|
|
|
46
46
|
|
|
47
47
|
/// Command-line interface for MD-Models CLI.
|
|
48
48
|
#[derive(Parser)]
|
|
49
|
-
#[command(name = "MD-Models CLI", version
|
|
49
|
+
#[command(name = "MD-Models CLI", version)]
|
|
50
50
|
#[command(about = "Validate and convert Markdown Data Models", long_about = None)]
|
|
51
51
|
struct Cli {
|
|
52
52
|
/// Subcommands for the CLI.
|
|
@@ -518,12 +518,12 @@ fn render_all_json_schemes(
|
|
|
518
518
|
) -> Result<(), Box<dyn Error>> {
|
|
519
519
|
let outdir = match outdir {
|
|
520
520
|
Some(outdir) => outdir,
|
|
521
|
-
None =>
|
|
521
|
+
None => return Err("Output directory (-o) is required for json-schema-all".into()),
|
|
522
522
|
};
|
|
523
523
|
|
|
524
524
|
// Check if the output is a directory
|
|
525
525
|
if !outdir.is_dir() && outdir.exists() {
|
|
526
|
-
|
|
526
|
+
return Err(format!("Output {} must be a directory", outdir.display()).into());
|
|
527
527
|
}
|
|
528
528
|
|
|
529
529
|
// If the output directory does not exist, create it
|
|
@@ -146,13 +146,13 @@ impl DataModel {
|
|
|
146
146
|
openai: bool,
|
|
147
147
|
) -> Result<String, Box<dyn Error>> {
|
|
148
148
|
if self.objects.is_empty() {
|
|
149
|
-
|
|
149
|
+
return Err("No objects found in the markdown file".into());
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
match obj_name {
|
|
153
153
|
Some(name) => {
|
|
154
154
|
if self.objects.iter().all(|o| o.name != name) {
|
|
155
|
-
|
|
155
|
+
return Err(format!("Object '{name}' not found in the markdown file").into());
|
|
156
156
|
}
|
|
157
157
|
Ok(serde_json::to_string_pretty(&to_json_schema(
|
|
158
158
|
self, &name, openai,
|
|
@@ -185,7 +185,7 @@ impl DataModel {
|
|
|
185
185
|
// ```
|
|
186
186
|
pub fn json_schema_all(&self, path: PathBuf, openai: bool) -> Result<(), Box<dyn Error>> {
|
|
187
187
|
if self.objects.is_empty() {
|
|
188
|
-
|
|
188
|
+
return Err("No objects found in the markdown file".into());
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
// Create the directory if it does not exist
|
|
@@ -565,6 +565,7 @@ mod tests {
|
|
|
565
565
|
name: "test1".to_string(),
|
|
566
566
|
is_array: false,
|
|
567
567
|
is_id: false,
|
|
568
|
+
is_iri: false,
|
|
568
569
|
dtypes: vec!["string".to_string()],
|
|
569
570
|
docstring: "".to_string(),
|
|
570
571
|
options: vec![],
|
|
@@ -582,6 +583,7 @@ mod tests {
|
|
|
582
583
|
name: "test2".to_string(),
|
|
583
584
|
is_array: false,
|
|
584
585
|
is_id: false,
|
|
586
|
+
is_iri: false,
|
|
585
587
|
dtypes: vec!["string".to_string()],
|
|
586
588
|
docstring: "".to_string(),
|
|
587
589
|
options: vec![],
|
|
@@ -634,6 +636,7 @@ mod tests {
|
|
|
634
636
|
name: "not_required".to_string(),
|
|
635
637
|
is_array: false,
|
|
636
638
|
is_id: false,
|
|
639
|
+
is_iri: false,
|
|
637
640
|
dtypes: vec!["string".to_string()],
|
|
638
641
|
docstring: "".to_string(),
|
|
639
642
|
options: vec![],
|
|
@@ -650,6 +653,7 @@ mod tests {
|
|
|
650
653
|
name: "required".to_string(),
|
|
651
654
|
is_array: false,
|
|
652
655
|
is_id: false,
|
|
656
|
+
is_iri: false,
|
|
653
657
|
dtypes: vec!["string".to_string()],
|
|
654
658
|
docstring: "".to_string(),
|
|
655
659
|
options: vec![],
|