feat(json-schema-2020-12): add support for contentEncoding keyword (#8644)

Refs #8513
This commit is contained in:
Vladimír Gorej
2023-05-10 14:20:05 +02:00
committed by GitHub
parent c15e69eb4f
commit 92088183c3
2 changed files with 8 additions and 4 deletions

View File

@@ -10,10 +10,11 @@ import classNames from "classnames"
* from JSON Schema 2020-12 validation vocabulary.
*/
const Constraint = ({ constraint }) => {
const isPattern = /^matches /.test(constraint)
const isStringRange = /characters$/.test(constraint)
const isContentMediaType = /^media type: /
const isStringRelated = isPattern || isStringRange || isContentMediaType
const isStringRelated =
/^matches /.test(constraint) || // pattern keyword
/characters$/.test(constraint) || // minLength, maxLength keywords
/^media type: /.test(constraint) || // contentMediaType keyword
/^encoding: /.test(constraint) // contentEncoding keyword
return (
<span

View File

@@ -296,6 +296,9 @@ export const stringifyConstraints = (schema) => {
if (schema?.contentMediaType) {
constraints.push(`media type: ${schema.contentMediaType}`)
}
if (schema?.contentEncoding) {
constraints.push(`encoding: ${schema.contentEncoding}`)
}
return constraints
}