Additional constraints for API
- Dominant language
- No language data
- Stars
- 52
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
JSON schema validation functionality has been added to CORE to support USDM schema-based rules. The CORE functionality relies version-specific schemas that are derived from the v3 and v4 API specifications.
The following additional constraints have been added to the schemas used for CORE validation, and it would probably make sense to add these into the API specification itself:
- `additionalProperties = false` for all model classes. As we now have the extension mechanism, there should be no need to add extra properties into classes. Adding this constraint also has the benefit that unintentional misspellings of attribute names are reported during schema validation.
- `minItems = 1` for required list/array properties. From a JSON Schema perspective, `required` simply means that the attribute must be present - there's no requirement for the attribute to have a value. In the same way that we use `minLength = 1` for required string values (so that empty strings are reported as errors), specifying `minItems = 1` for list/arrary properties ensures that the model-based cardinalities are enforced during schema validataion.
Contributor guide
Research direction
Locate the version-specific schemas and their v3 and v4 API specification sources used by CORE validation. Review every model class and required list or array property, then confirm the API specifications express the requested constraints and that schema validation accepts valid models while rejecting extra properties and empty required lists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100