Skip to content

Consistent handling of enumerated categories #126

@alink-volpe

Description

@alink-volpe

The problem: The same enumerated categories fields appear in several parts of the schema. For example, the following appears in link, segment, link_tod, segment_tod:

{ 

            "name": "bike_facility", 

            "type": "string", 

            "description": "Optional. Types of bicycle accommodation based on the National Bikeway Network Data Template (Table 1-A at https://nmtdev.ornl.gov/assets/templates/NBN_DataTemplates_final.pdf)", 

            "categories": [ 

                "unseparated bike lane", 

                "buffered bike lane", 

                "separated bike lane", 

                "counter-flow bike lane", 

                "paved shoulder", 

                "shared lane", 

                "shared use path", 

                "off-road unpaved trail", 

                "other", 

                "none" 

            ] 

        }, 

Solution: Implement subschemas to define these enumerations once. Something like :


{ 

  "$id": "bike_facility_enum", 

  "type": "object", 

  "description": "Optional. Types of bicycle accommodation based on the National Bikeway Network Data Template (Table 1-A at https://nmtdev.ornl.gov/assets/templates/NBN_DataTemplates_final.pdf)", 

            "categories": [ 

                "unseparated bike lane", 

                "buffered bike lane", 

                "separated bike lane", 

                "counter-flow bike lane", 

                "paved shoulder", 

                "shared lane", 

                "shared use path", 

                "off-road unpaved trail", 

                "other", 

                "none" 

            ] 

} 

Then, in the link schema and others that reference the enumeration, include a reference to the relevant enumerated list:

"bike facility":  { 

"$ref: bike_facility_enum 
} 

For some examples, see:

https://specs.frictionlessdata.io/patterns/#implementations-13

https://json-schema.org/learn/getting-started-step-by-step

https://opis.io/json-schema/2.x/references.html

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions