Root Schema Has Name¶
Root Schema Has Name
is a Context Constraint that checks every schema with a root key and ensures there is a field called name
.
Usage Example¶
In this example, a name
field has been added, allowing it to pass the constraint.
schema:
name: test_schema
root: test_root
fields:
- name: name
type: string
- name: test_field
type: string
In the below example, test_schema
does not have a field called name
, and would fail the Root Schema Has Name
constraint. To pass this constraint, a field called name
would need to be added.
schema:
name: test_schema
root: test_root
fields:
- name: test_field
type: string
In this example, a name
field has been added, but it is empty triggering, a LanguageError
in parse_and_load
.
schema:
name: test_name
root: test_root
fields:
- name:
type: string
In this example, the name
field is missing, triggering a LanguageError
in parse_and_load
.
schema:
name: test_name
root: test_root
fields:
type: string
In this example, the schema name
field is empty, triggering a ParserError
in parse_and_load
.
schema:
name:
root: test_root
fields:
- name: name
type: string
In this example, the schema name
field is missing, triggering a ParserError
in parse_and_load
.
schema:
root: test_root
fields:
- name: name
type: string
In this example, we use two schemas to create a non-unique definition for AacType
, triggering a LanguageError
in root_schema_must_have_name
.
schema:
name: Schema
extends:
- package: aac.lang
name: AacType
package: aac.lang
root: schema
description: |
A definition that defines the schema/structure of data.
fields:
- name: extends
type: SchemaExtension[]
description: |
A list of Schema definition names that this definition inherits from.
- name: test
type: SchemaExtension[]
description: |
A list of Schema definition names that this definition inherits from.
- name: modifiers
type: dataref(modifier.name)[]
description:
A means of further defining the schema and how it can be used within the model.
- name: root
type: string
description: |
The root key to use when declaring an instance of the type in yaml/aac files.
- name: fields
type: Field[]
description: |
A list of fields that make up the definition.
is_required: true
- name: requirements
type: dataref(req.id)[]
description: |
A list of requirements associated with this schema.
- name: constraints
type: SchemaConstraintAssignment[]
schema:
name: AacType
package: wrong_package
description: |
A definition that defines the schema/structure of data.
fields:
- name: name
type: string
- name: test_field
type: string
** NOTE ** The
Unknown Location
andNo file to reference
are valid location returns for the error situations encountered in this constraint.