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.
root_schema_without_name_language_error1 = """
schema:
name: test_name
root: test_root
fields:
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.
root_schema_without_name_language_error1 = """
schema:
name: test_name
root: test_root
"""
In this example, a name field has been added, but it is empty triggering, a LanguageError in parse_and_load.
root: test_root
fields:
- name: name
type: string
"""
In this example, the name field is missing, triggering a LanguageError in parse_and_load.
fields:
- name: name
type: string
"""
In this example, the schema name field is empty, triggering a ParserError in parse_and_load.
extends:
- package: aac.lang
name: AacType
package: aac.lang
root: schema
description: |
In this example, the schema name field is missing, triggering a ParserError in parse_and_load.
type: SchemaExtension[]
description: |
A list of Schema definition names that this definition inherits from.
- name: test
type: SchemaExtension[]
In this example, we use two schemas to create a non-unique definition for AacType , triggering a LanguageError in root_schema_must_have_name.
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_root_with_different_package = """
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 LocationandNo file to referenceare valid location returns for the error situations encountered in this constraint.