Skip to content

Clearer definition of fields for capability - single type for fields #205

@TioBorracho

Description

@TioBorracho

Summary

Currently extends field is defined as oneof of single string vs array of strings. This makes validation and usage really complicated where just an array of strings where there is a validation for a single item in some cases would be much simpler

source/schemas/capability.json

Motivation

Having structures with non-defined types for fields make implementations harder where there needs to be validations for types. In this case it seems unnecesary as replacing a single string for an array of strings, and adding the restriction of a single item would be much simpler

Goals

  • Simplify implementation
  • define clearer types for fields

Detailed Design

  • Data Structures: D

  • Replace extends field in capability for array only

{
          "type": "object",
          "properties": {
            "extends": {
              "oneOf": [
                {
                  "type": "string",
                  "pattern": "^[a-z][a-z0-9]*(?:\\.[a-z][a-z0-9_]*)+$"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9]*(?:\\.[a-z][a-z0-9_]*)+$"
                  },
                  "minItems": 1
                }
              ],
              "description": "Parent capability(s) this extends. Present for extensions, absent for root capabilities. Use array for multi-parent extensions."
            }
          }
        }

by

{
          "type": "object",
          "properties": {
            "extends": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[a-z][a-z0-9]*(?:\\.[a-z][a-z0-9_]*)+$"
                },
                "minItems": 1
              }
              "description": "Parent capability(s) this extends. Present for extensions, absent for root capabilities."
            }
          }
        }

Risks and Mitigations

  • Backward Compatibility:

This is a breaking change as defined, unless we keep the oneof versino but discourage the use of single string.

Metadata

Metadata

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