Skip to main content

Model builder plugin for oarepo-polymorphic

Project description

Polymorphic model builder plugin

An OARepo Model Builder plugin to generate invenio sources for polymorphic models.

Installation

pip install oarepo-model-builder-polymorphic

Usage

What is polymorphic model?

A polymorphic model is a dict that can be defined by multiple schemas. Which schema is used depends on a value of a present field (that is shared across all the schemas).

Polymorphic model can be used, for example, to express inheritance:

extension1{}:
  disc: { type: keyword }
  a: { type: keyword }

extension2{}:
  disc: { type: keyword }
  b: { type: keyword }

record:
  properties:
    a:
      type: polymorphic
      discriminator: disc
      schemas:
        "1": { use: "/extension1" }
        "2": { use: "/extension2" }

The following are valid instances:

a:
  disc: "1"
  a: "blah"
---
a:
  disc: "2"
  b: "blah"

Invalid instance:

a:
  disc: "3"
  b: "blah"
---
a:
  disc: "1"
  a: "blah"
  b: "blah"

If the "disc" field contains value "1", first extension schema will be used, if it contains value "2", second schema will be used. Any other value is not valid.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oarepo-model-builder-polymorphic-1.0.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file oarepo-model-builder-polymorphic-1.0.2.tar.gz.

File metadata

File hashes

Hashes for oarepo-model-builder-polymorphic-1.0.2.tar.gz
Algorithm Hash digest
SHA256 7340fa1598ad8bb56b629be133688c21e1aa8113503933e930697425bcd7442e
MD5 d549eb3ddf9cd4df049a5e29f9dd954d
BLAKE2b-256 cfb718d8ff159718f670afdebd91d27d345aee45e648eeb4c1c45c393e0bdec6

See more details on using hashes here.

File details

Details for the file oarepo_model_builder_polymorphic-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for oarepo_model_builder_polymorphic-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a80b5fe7710a697eb41e3c516b1ac733f042b2a7d1208ccf7304ef3490f33563
MD5 4f377dc17239673ad236f3bf0b27eebd
BLAKE2b-256 e675847b7b35daeb71a450404419413843ef03d30ec41800e6f2c71227e14a05

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page