Skip to content
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

add missing basket examples #542

Merged
merged 2 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions schema_salad/tests/basket.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# N.B.: this example is used in a test that needs a file without $base,
# so please do not include $base here.
- name: Basket
doc: A basket of products.
type: record
documentRoot: true
fields:
product: string
price: float
basket:
- product: bananas
price: 0.39
per: pound
weight: 1
- product: cucumbers
price: 0.79
per: item
count: 3
54 changes: 54 additions & 0 deletions schema_salad/tests/basket_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# N.B.: this example is used in a test that needs a file without $base,
# so please do not include $base here.
- name: Product
doc: |
The base type for a product. This is an abstract type, so it
can't be used directly, but can be used to define other types.
type: record
abstract: true
fields:
product: string
price: float

- name: ByWeight
doc: |
A product, sold by weight. Products may be sold by pound or by
kilogram. Weights may be fractional.
type: record
extends: Product
fields:
per:
type:
type: enum
symbols:
- pound
- kilogram
jsonldPredicate: "#per"
weight: float

- name: ByCount
doc: |
A product, sold by count. The count must be a integer value.
type: record
extends: Product
fields:
per:
type:
type: enum
symbols:
- item
jsonldPredicate: "#per"
count: int

- name: Basket
doc: |
A basket of products. The 'documentRoot' field indicates it is a
valid starting point for a document. The 'basket' field will
validate subtypes of 'Product' (ByWeight and ByCount).
type: record
documentRoot: true
fields:
basket:
type:
type: array
items: Product
2 changes: 1 addition & 1 deletion schema_salad/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ def get_data_uri(resource_path: str) -> str:

cwl_file_uri = get_data_uri("tests/test_schema/CommonWorkflowLanguage.yml")
metaschema_file_uri = get_data_uri("metaschema/metaschema.yml")
basket_file_uri = get_data_uri("basket.yml")
basket_file_uri = get_data_uri("tests/basket_schema.yml")