mdmodels-core 0.2.6__tar.gz → 0.2.7__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.
Files changed (183) hide show
  1. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/Cargo.lock +1 -1
  2. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/Cargo.toml +1 -1
  3. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/PKG-INFO +1 -1
  4. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/pyproject.toml +1 -1
  5. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/bin/cli.rs +35 -2
  6. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/exporters.rs +25 -10
  7. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/json/export.rs +1 -0
  8. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/json/import.rs +23 -0
  9. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/json/schema.rs +127 -2
  10. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/typescript-zod.jinja +11 -5
  11. mdmodels_core-0.2.7/tests/data/expected_typescript_zod.ts +70 -0
  12. mdmodels_core-0.2.6/tests/data/expected_typescript_zod.ts → mdmodels_core-0.2.7/tests/data/expected_typescript_zod_json_ld.ts +10 -6
  13. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/.github/scripts/generate_types.sh +0 -0
  14. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/.github/workflows/assets.yml +0 -0
  15. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/.github/workflows/docs.yml +0 -0
  16. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/.github/workflows/format.yml +0 -0
  17. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/.github/workflows/lint.yml +0 -0
  18. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/.github/workflows/npm_bundler.yml +0 -0
  19. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/.github/workflows/npm_web.yml +0 -0
  20. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/.github/workflows/publish.yml +0 -0
  21. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/.github/workflows/publish_pypi.yml +0 -0
  22. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/.github/workflows/publish_test_pypi.yml +0 -0
  23. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/.github/workflows/test.yml +0 -0
  24. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/.gitignore +0 -0
  25. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/.pre-commit-config.yaml +0 -0
  26. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/LICENSE.md +0 -0
  27. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/README.md +0 -0
  28. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/build.rs +0 -0
  29. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/.gitignore +0 -0
  30. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/book.toml +0 -0
  31. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/SUMMARY.md +0 -0
  32. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/cli/cli.md +0 -0
  33. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/cli/code_generation.md +0 -0
  34. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/cli/llm.md +0 -0
  35. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/cli/pipelines.md +0 -0
  36. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/cli/schema_validation.md +0 -0
  37. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/examples/database_models.md +0 -0
  38. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/examples/examples.md +0 -0
  39. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/examples/hello_md_models.md +0 -0
  40. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/examples/union_types.md +0 -0
  41. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/exporters/apis.md +0 -0
  42. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/exporters/documentation.md +0 -0
  43. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/exporters/exporters.md +0 -0
  44. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/exporters/languages.md +0 -0
  45. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/exporters/schemas.md +0 -0
  46. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/faq/faq.md +0 -0
  47. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/introduction.md +0 -0
  48. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/quickstart.md +0 -0
  49. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/syntax/best_practices.md +0 -0
  50. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/syntax/descriptions.md +0 -0
  51. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/syntax/enums.md +0 -0
  52. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/syntax/full_example.md +0 -0
  53. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/syntax/objects.md +0 -0
  54. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/syntax/preambles.md +0 -0
  55. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/syntax/property_options.md +0 -0
  56. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/syntax/semantics.md +0 -0
  57. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/docs/src/syntax/syntax.md +0 -0
  58. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/attribute.rs +0 -0
  59. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/bindings/python.rs +0 -0
  60. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/bindings/wasm.rs +0 -0
  61. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/datamodel.rs +0 -0
  62. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/error.rs +0 -0
  63. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/json/validation.rs +0 -0
  64. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/lib.rs +0 -0
  65. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/linkml/export.rs +0 -0
  66. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/linkml/import.rs +0 -0
  67. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/linkml/schema.rs +0 -0
  68. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/llm/extraction.rs +0 -0
  69. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/llm/input.rs +0 -0
  70. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/markdown/frontmatter.rs +0 -0
  71. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/markdown/parser.rs +0 -0
  72. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/markdown/position.rs +0 -0
  73. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/object.rs +0 -0
  74. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/option.rs +0 -0
  75. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/pipeline.rs +0 -0
  76. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/tree.rs +0 -0
  77. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/validation.rs +0 -0
  78. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/src/xmltype.rs +0 -0
  79. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/golang.jinja +0 -0
  80. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/graphql.jinja +0 -0
  81. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/julia.jinja +0 -0
  82. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/markdown-compact.jinja +0 -0
  83. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/markdown.jinja +0 -0
  84. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/mermaid.jinja +0 -0
  85. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/mkdocs.jinja +0 -0
  86. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/protobuf.jinja +0 -0
  87. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/python-dataclass.jinja +0 -0
  88. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/python-macros.jinja +0 -0
  89. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/python-pydantic-xml.jinja +0 -0
  90. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/python-pydantic.jinja +0 -0
  91. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/rust.jinja +0 -0
  92. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/shacl.jinja +0 -0
  93. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/shex.jinja +0 -0
  94. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/typescript.jinja +0 -0
  95. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/templates/xml-schema.jinja +0 -0
  96. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_golang.go +0 -0
  97. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_golang_gorm.go +0 -0
  98. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_graphql.graphql +0 -0
  99. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_internal_full_schema.json +0 -0
  100. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_internal_schema.json +0 -0
  101. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_internal_schema_inheritance.json +0 -0
  102. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_invalid_complete.json +0 -0
  103. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_json_schema.json +0 -0
  104. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_json_schema_openai.json +0 -0
  105. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_julia.jl +0 -0
  106. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_linkml.yml +0 -0
  107. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_mermaid.md +0 -0
  108. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_meta_json_schema.json +0 -0
  109. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_mkdocs.md +0 -0
  110. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_proto.proto +0 -0
  111. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_protobuf.proto +0 -0
  112. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_pydantic.py +0 -0
  113. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_pydantic_unitdef.py +0 -0
  114. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_python_dc.py +0 -0
  115. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_python_pydantic_xml.py +0 -0
  116. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_rust.rs +0 -0
  117. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_rust_forbidden.rs +0 -0
  118. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_shacl.ttl +0 -0
  119. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_shex.shex +0 -0
  120. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_typescript.ts +0 -0
  121. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/expected_xml_schema.xsd +0 -0
  122. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/invalid_dataset.json +0 -0
  123. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model.md +0 -0
  124. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_compact.md +0 -0
  125. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_duplicates.md +0 -0
  126. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_forbidden_names.md +0 -0
  127. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_full_documentation.md +0 -0
  128. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_golang_gorm.md +0 -0
  129. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_inheritance.md +0 -0
  130. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_inheritance_invalid.md +0 -0
  131. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_invalid_complete.md +0 -0
  132. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_invalid_names.md +0 -0
  133. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_invalid_xml_option.md +0 -0
  134. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_invalid_xml_wrapped.md +0 -0
  135. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_json_schema.md +0 -0
  136. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_json_schema_openai.md +0 -0
  137. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_json_validation.md +0 -0
  138. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_merge.md +0 -0
  139. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_merge_invalid.md +0 -0
  140. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_meta.md +0 -0
  141. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_missing_types.md +0 -0
  142. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_multiple_keyword.md +0 -0
  143. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_multiple_types.md +0 -0
  144. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_multiple_types_invalid.md +0 -0
  145. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_no_frontmatter.md +0 -0
  146. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_no_objects.md +0 -0
  147. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_options.md +0 -0
  148. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_unitdef.md +0 -0
  149. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/model_w_html.md +0 -0
  150. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/old_schema.json +0 -0
  151. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/data/valid_dataset.json +0 -0
  152. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/go/Dockerfile +0 -0
  153. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/go/generated.go +0 -0
  154. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/go/generated_test.go +0 -0
  155. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/go/go.mod +0 -0
  156. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/julia/test.jl +0 -0
  157. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/python/.gitignore +0 -0
  158. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/python/Dockerfile +0 -0
  159. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/python/requirements.txt +0 -0
  160. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/python/test_dataclasses.py +0 -0
  161. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/python/test_pydantic.py +0 -0
  162. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/python/test_pydantic_xml.py +0 -0
  163. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/typescript/.gitignore +0 -0
  164. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/typescript/Dockerfile +0 -0
  165. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/typescript/package-lock.json +0 -0
  166. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/typescript/package.json +0 -0
  167. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/typescript/test.ts +0 -0
  168. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/envs/typescript/tsconfig.json +0 -0
  169. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/integration_tests.rs +0 -0
  170. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/test_pipeline.toml +0 -0
  171. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/test_pipeline_per_spec.toml +0 -0
  172. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/tests/test_pipeline_per_spec_invalid.toml +0 -0
  173. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/types/README.md +0 -0
  174. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/types/equation/equation-internal.json +0 -0
  175. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/types/equation/equation.json +0 -0
  176. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/types/equation/equation.md +0 -0
  177. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/types/equation/equation.xsd +0 -0
  178. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/types/equation/gen.toml +0 -0
  179. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/types/unit-definition/gen.toml +0 -0
  180. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/types/unit-definition/unit-definition-internal.json +0 -0
  181. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/types/unit-definition/unit-definition.json +0 -0
  182. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/types/unit-definition/unit-definition.md +0 -0
  183. {mdmodels_core-0.2.6 → mdmodels_core-0.2.7}/types/unit-definition/unit-definition.xsd +0 -0
@@ -1253,7 +1253,7 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
1253
1253
 
1254
1254
  [[package]]
1255
1255
  name = "mdmodels"
1256
- version = "0.2.6"
1256
+ version = "0.2.7"
1257
1257
  dependencies = [
1258
1258
  "assert_cmd",
1259
1259
  "clap",
@@ -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.2.6"
5
+ version = "0.2.7"
6
6
  edition = "2021"
7
7
  license = "MIT"
8
8
  repository = "https://github.com/FAIRChemistry/md-models"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mdmodels_core
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "mdmodels_core"
7
- version = "0.2.6"
7
+ version = "0.2.7"
8
8
  description = "A tool to generate models, code and schemas from markdown files"
9
9
  requires-python = ">=3.8"
10
10
  classifiers = [
@@ -26,6 +26,7 @@ use colored::Colorize;
26
26
  use log::error;
27
27
  use mdmodels::{
28
28
  datamodel::DataModel,
29
+ error::DataModelError,
29
30
  exporters::{render_jinja_template, Templates},
30
31
  json::validation::validate_json,
31
32
  linkml::export::serialize_linkml,
@@ -34,7 +35,13 @@ use mdmodels::{
34
35
  };
35
36
  use serde::{Deserialize, Serialize};
36
37
  use std::{
37
- collections::HashMap, error::Error, fmt::Display, fs, io::Write, path::PathBuf, str::FromStr,
38
+ collections::HashMap,
39
+ error::Error,
40
+ fmt::Display,
41
+ fs,
42
+ io::Write,
43
+ path::{Path, PathBuf},
44
+ str::FromStr,
38
45
  };
39
46
 
40
47
  /// Command-line interface for MD-Models CLI.
@@ -246,7 +253,13 @@ fn validate(args: ValidateArgs) -> Result<(), Box<dyn Error>> {
246
253
 
247
254
  let path = resolve_input_path(&args.input);
248
255
 
249
- match DataModel::from_markdown(&path) {
256
+ if is_json_schema(&path)? {
257
+ return validate_from_json_schema(&path);
258
+ }
259
+
260
+ let model = DataModel::from_markdown(&path);
261
+
262
+ match model {
250
263
  Ok(_) => {
251
264
  print_validation_result(true);
252
265
  Ok(())
@@ -259,6 +272,26 @@ fn validate(args: ValidateArgs) -> Result<(), Box<dyn Error>> {
259
272
  }
260
273
  }
261
274
 
275
+ /// Validates a JSON schema file.
276
+ ///
277
+ /// # Arguments
278
+ ///
279
+ /// * `path` - Path to the JSON schema file.
280
+ fn validate_from_json_schema(path: &Path) -> Result<(), Box<dyn Error>> {
281
+ if let Err(err) = DataModel::from_json_schema(path) {
282
+ match err {
283
+ DataModelError::ValidationError(validator) => {
284
+ validator.log_result();
285
+ Err("Model is invalid".into())
286
+ }
287
+ _ => Err(err.into()),
288
+ }
289
+ } else {
290
+ print_validation_result(true);
291
+ Ok(())
292
+ }
293
+ }
294
+
262
295
  /// Prints the result of the validation.
263
296
  ///
264
297
  /// # Arguments
@@ -245,6 +245,10 @@ pub fn render_jinja_template(
245
245
  // a primary key.
246
246
  let mut artificial_fields = HashMap::new();
247
247
 
248
+ // If there is no config, create an empty one
249
+ // This is necessary to avoid errors when rendering the template
250
+ let config = config.cloned().unwrap_or_default();
251
+
248
252
  // Perform type conversions and filtering based on the template
249
253
  match template {
250
254
  Templates::XmlSchema => convert_model_types(model, &XSD_TYPE_MAPS),
@@ -269,10 +273,8 @@ pub fn render_jinja_template(
269
273
  sort_by_dependency(model);
270
274
  }
271
275
  Templates::Golang => {
272
- if let Some(config) = config {
273
- if config.contains_key("gorm") {
274
- add_id_pks(model, &mut artificial_fields);
275
- }
276
+ if config.contains_key("gorm") {
277
+ add_id_pks(model, &mut artificial_fields);
276
278
  }
277
279
  }
278
280
  Templates::Rust => {
@@ -622,12 +624,7 @@ fn has_id(object: &Object) -> bool {
622
624
  /// # Arguments
623
625
  ///
624
626
  /// * `model` - The data model whose types are to be converted.
625
- fn convert_astropy_types(model: &mut DataModel, config: &Option<&HashMap<String, String>>) {
626
- if config.is_none() {
627
- return;
628
- }
629
-
630
- let config = config.unwrap();
627
+ fn convert_astropy_types(model: &mut DataModel, config: &HashMap<String, String>) {
631
628
  if !config.contains_key("astropy") {
632
629
  return;
633
630
  }
@@ -979,6 +976,24 @@ mod tests {
979
976
  assert_eq!(rendered, expected);
980
977
  }
981
978
 
979
+ #[test]
980
+ fn test_convert_to_typescript_zod_json_ld() {
981
+ // Arrange
982
+ let rendered = build_and_convert(
983
+ "tests/data/model.md",
984
+ Templates::TypescriptZod,
985
+ Some(&HashMap::from([(
986
+ "json-ld".to_string(),
987
+ "true".to_string(),
988
+ )])),
989
+ );
990
+
991
+ // Assert
992
+ let expected = fs::read_to_string("tests/data/expected_typescript_zod_json_ld.ts")
993
+ .expect("Could not read expected file");
994
+ assert_eq!(rendered, expected);
995
+ }
996
+
982
997
  #[test]
983
998
  fn test_convert_to_pydantic() {
984
999
  // Arrange
@@ -616,6 +616,7 @@ impl TryFrom<&Attribute> for schema::Property {
616
616
  enum_values,
617
617
  any_of: None,
618
618
  all_of: None,
619
+ examples: Vec::new(),
619
620
  })
620
621
  }
621
622
  }
@@ -930,4 +930,27 @@ mod tests {
930
930
  assert_eq!(clean_key("Test__Hello"), "TEST_HELLO");
931
931
  assert_eq!(clean_key("!Test"), "TEST");
932
932
  }
933
+
934
+ #[test]
935
+ fn test_additional_properties_object() {
936
+ let schema = json!({
937
+ "title": "Test",
938
+ "type": "object",
939
+ "properties": {
940
+ "test": {
941
+ "type": "string"
942
+ }
943
+ },
944
+ "additionalProperties": {
945
+ "type": "string"
946
+ }
947
+ });
948
+
949
+ let schema: SchemaObject = serde_json::from_value(schema).unwrap();
950
+ let data_model = DataModel::try_from(schema.clone()).unwrap();
951
+
952
+ assert!(schema.additional_properties);
953
+ assert_eq!(data_model.objects.len(), 1);
954
+ assert_eq!(data_model.objects[0].attributes.len(), 1);
955
+ }
933
956
  }
@@ -54,7 +54,10 @@ pub struct SchemaObject {
54
54
  pub schema: Option<String>,
55
55
  #[serde(rename = "$id", skip_serializing_if = "Option::is_none")]
56
56
  pub id: Option<String>,
57
- #[serde(default = "generate_unique_title")]
57
+ #[serde(
58
+ default = "generate_unique_title",
59
+ deserialize_with = "deserialize_title_with_whitespace_removal"
60
+ )]
58
61
  pub title: String,
59
62
  #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
60
63
  pub dtype: Option<DataType>,
@@ -70,7 +73,11 @@ pub struct SchemaObject {
70
73
  pub definitions: BTreeMap<String, SchemaType>,
71
74
  #[serde(default)]
72
75
  pub required: Vec<String>,
73
- #[serde(rename = "additionalProperties", default = "default_false")]
76
+ #[serde(
77
+ rename = "additionalProperties",
78
+ default = "default_false",
79
+ deserialize_with = "deserialize_additional_properties"
80
+ )]
74
81
  pub additional_properties: bool,
75
82
  }
76
83
 
@@ -118,6 +125,8 @@ pub struct Property {
118
125
  pub all_of: Option<Vec<Item>>,
119
126
  #[serde(skip_serializing_if = "skip_empty", rename = "enum")]
120
127
  pub enum_values: Option<Vec<String>>,
128
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
129
+ pub examples: Vec<Value>,
121
130
  }
122
131
 
123
132
  #[derive(Debug, Deserialize, Variantly, Clone)]
@@ -356,6 +365,80 @@ fn default_false() -> bool {
356
365
  false
357
366
  }
358
367
 
368
+ fn deserialize_title_with_whitespace_removal<'de, D>(deserializer: D) -> Result<String, D::Error>
369
+ where
370
+ D: serde::Deserializer<'de>,
371
+ {
372
+ use serde::de::{self, Visitor};
373
+ use std::fmt;
374
+
375
+ struct TitleVisitor;
376
+
377
+ impl<'de> Visitor<'de> for TitleVisitor {
378
+ type Value = String;
379
+
380
+ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
381
+ formatter.write_str("a string")
382
+ }
383
+
384
+ fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
385
+ where
386
+ E: de::Error,
387
+ {
388
+ Ok(value.chars().filter(|c| !c.is_whitespace()).collect())
389
+ }
390
+
391
+ fn visit_string<E>(self, value: String) -> Result<Self::Value, E>
392
+ where
393
+ E: de::Error,
394
+ {
395
+ Ok(value.chars().filter(|c| !c.is_whitespace()).collect())
396
+ }
397
+ }
398
+
399
+ deserializer.deserialize_str(TitleVisitor)
400
+ }
401
+
402
+ fn deserialize_additional_properties<'de, D>(deserializer: D) -> Result<bool, D::Error>
403
+ where
404
+ D: serde::Deserializer<'de>,
405
+ {
406
+ use serde::de::{self, Visitor};
407
+ use serde_json::Value;
408
+ use std::fmt;
409
+
410
+ struct AdditionalPropertiesVisitor;
411
+
412
+ impl<'de> Visitor<'de> for AdditionalPropertiesVisitor {
413
+ type Value = bool;
414
+
415
+ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
416
+ formatter.write_str("a boolean or an object")
417
+ }
418
+
419
+ fn visit_bool<E>(self, value: bool) -> Result<Self::Value, E>
420
+ where
421
+ E: de::Error,
422
+ {
423
+ Ok(value)
424
+ }
425
+
426
+ fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
427
+ where
428
+ M: de::MapAccess<'de>,
429
+ {
430
+ // Consume all entries in the map to avoid "trailing characters" error
431
+ while map.next_entry::<String, Value>()?.is_some() {
432
+ // Just consume and discard
433
+ }
434
+ // Any object/map means additionalProperties = true
435
+ Ok(true)
436
+ }
437
+ }
438
+
439
+ deserializer.deserialize_any(AdditionalPropertiesVisitor)
440
+ }
441
+
359
442
  #[cfg(test)]
360
443
  mod tests {
361
444
  use super::*;
@@ -371,4 +454,46 @@ mod tests {
371
454
  assert_eq!(DataType::from_str("object").unwrap(), DataType::Object);
372
455
  assert_eq!(DataType::from_str("array").unwrap(), DataType::Array);
373
456
  }
457
+
458
+ #[test]
459
+ /// Tests that title deserialization removes all whitespaces from the title string.
460
+ fn test_title_whitespace_removal() {
461
+ use serde_json;
462
+
463
+ // Test with spaces, tabs, and newlines
464
+ let json_with_whitespace = r#"
465
+ {
466
+ "title": "My Test Title",
467
+ "type": "object",
468
+ "properties": {}
469
+ }
470
+ "#;
471
+
472
+ let schema: SchemaObject = serde_json::from_str(json_with_whitespace).unwrap();
473
+ assert_eq!(schema.title, "MyTestTitle");
474
+
475
+ // Test with various whitespace characters
476
+ let json_with_various_whitespace = r#"
477
+ {
478
+ "title": " My\t\nTest\r Title ",
479
+ "type": "object",
480
+ "properties": {}
481
+ }
482
+ "#;
483
+
484
+ let schema2: SchemaObject = serde_json::from_str(json_with_various_whitespace).unwrap();
485
+ assert_eq!(schema2.title, "MyTestTitle");
486
+
487
+ // Test with no whitespace (should remain unchanged)
488
+ let json_no_whitespace = r#"
489
+ {
490
+ "title": "MyTitle",
491
+ "type": "object",
492
+ "properties": {}
493
+ }
494
+ "#;
495
+
496
+ let schema3: SchemaObject = serde_json::from_str(json_no_whitespace).unwrap();
497
+ assert_eq!(schema3.title, "MyTitle");
498
+ }
374
499
  }
@@ -93,21 +93,27 @@
93
93
  {# Code structure starts here #}
94
94
  import { z } from 'zod';
95
95
 
96
+ {% if "json-ld" in config %}
96
97
  // JSON-LD Types
97
- export const JsonLdContextSchema = z.record(z.any());
98
+ export const JsonLdContextSchema = z.record(z.string());
98
99
 
99
100
  export const JsonLdSchema = z.object({
100
- '@context': JsonLdContextSchema.optional(),
101
- '@id': z.string().optional(),
102
- '@type': z.string().optional(),
101
+ '@context': JsonLdContextSchema.optional().nullable(),
102
+ '@id': z.string().optional().nullable(),
103
+ '@type': z.string().optional().nullable(),
103
104
  });
104
105
 
106
+ const BaseSchema = JsonLdSchema;
107
+ {% else %}
108
+ const BaseSchema = z.object({});
109
+ {%- endif %}
110
+
105
111
  // {% if title %}{{ title }}{% else %}Model{% endif %} Type definitions
106
112
  {%- for object in objects %}
107
113
  {%- if object.docstring %}
108
114
  // {{ wrap(object.docstring, 70, "", "// ", None) }}
109
115
  {%- endif %}
110
- export const {{ object.name }}Schema = z.lazy(() => JsonLdSchema.extend({
116
+ export const {{ object.name }}Schema = z.lazy(() => BaseSchema.extend({
111
117
  {%- for attr in object.attributes %}
112
118
  {{ attr.name }}: {{ wrap_zod_type(get_type(attr), attr) }}{% if attr.docstring %}.describe(`
113
119
  {{ wrap(attr.docstring, 70, "", " ", None) }}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * This file contains Zod schema definitions for data validation.
3
+ *
4
+ * Zod is a TypeScript-first schema declaration and validation library.
5
+ * It allows you to create schemas that validate data at runtime while
6
+ * providing static type inference.
7
+ *
8
+ * Usage example:
9
+ * ```typescript
10
+ * import { TestSchema } from './schemas';
11
+ *
12
+ * // Validates data at runtime
13
+ * const result = TestSchema.parse(data);
14
+ *
15
+ * // Type-safe - result has correct TypeScript types
16
+ * console.log(result.name);
17
+ *
18
+ * // Will throw error if validation fails
19
+ * try {
20
+ * TestSchema.parse(invalidData);
21
+ * } catch (err) {
22
+ * console.error(err);
23
+ * }
24
+ * ```
25
+ *
26
+ * @see https://github.com/colinhacks/zod
27
+ *
28
+ * WARNING: This is an auto-generated file.
29
+ * Do not edit directly - any changes will be overwritten.
30
+ */
31
+
32
+
33
+ import { z } from 'zod';
34
+
35
+
36
+ const BaseSchema = z.object({});
37
+
38
+ // Model Type definitions
39
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do
40
+ // eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
41
+ // ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
42
+ // aliquip ex ea commodo consequat.
43
+ export const TestSchema = z.lazy(() => BaseSchema.extend({
44
+ name: z.string().describe(`
45
+ The name of the test. This is a unique identifier that helps track
46
+ individual test cases across the system. It should be descriptive
47
+ and follow the standard naming conventions.
48
+ `),
49
+ number: z.union([z.number(), z.string()]).nullable(),
50
+ test2: z.array(Test2Schema),
51
+ ontology: OntologySchema.nullable(),
52
+ }));
53
+
54
+ export type Test = z.infer<typeof TestSchema>;
55
+
56
+ export const Test2Schema = z.lazy(() => BaseSchema.extend({
57
+ names: z.array(z.string()),
58
+ number: z.number().nullable(),
59
+ }));
60
+
61
+ export type Test2 = z.infer<typeof Test2Schema>;
62
+
63
+ // Model Enum definitions
64
+ export enum Ontology {
65
+ ECO = 'https://www.evidenceontology.org/term/',
66
+ GO = 'https://amigo.geneontology.org/amigo/term/',
67
+ SIO = 'http://semanticscience.org/resource/',
68
+ }
69
+
70
+ export const OntologySchema = z.nativeEnum(Ontology);
@@ -32,21 +32,25 @@
32
32
 
33
33
  import { z } from 'zod';
34
34
 
35
+
35
36
  // JSON-LD Types
36
- export const JsonLdContextSchema = z.record(z.any());
37
+ export const JsonLdContextSchema = z.record(z.string());
37
38
 
38
39
  export const JsonLdSchema = z.object({
39
- '@context': JsonLdContextSchema.optional(),
40
- '@id': z.string().optional(),
41
- '@type': z.string().optional(),
40
+ '@context': JsonLdContextSchema.optional().nullable(),
41
+ '@id': z.string().optional().nullable(),
42
+ '@type': z.string().optional().nullable(),
42
43
  });
43
44
 
45
+ const BaseSchema = JsonLdSchema;
46
+
47
+
44
48
  // Model Type definitions
45
49
  // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do
46
50
  // eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
47
51
  // ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
48
52
  // aliquip ex ea commodo consequat.
49
- export const TestSchema = z.lazy(() => JsonLdSchema.extend({
53
+ export const TestSchema = z.lazy(() => BaseSchema.extend({
50
54
  name: z.string().describe(`
51
55
  The name of the test. This is a unique identifier that helps track
52
56
  individual test cases across the system. It should be descriptive
@@ -59,7 +63,7 @@ export const TestSchema = z.lazy(() => JsonLdSchema.extend({
59
63
 
60
64
  export type Test = z.infer<typeof TestSchema>;
61
65
 
62
- export const Test2Schema = z.lazy(() => JsonLdSchema.extend({
66
+ export const Test2Schema = z.lazy(() => BaseSchema.extend({
63
67
  names: z.array(z.string()),
64
68
  number: z.number().nullable(),
65
69
  }));
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes