Skip to content

Commit

Permalink
feat(json-schema-2020-12): add support for contentMediaType keyword (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n committed May 10, 2023
1 parent 5f6423c commit c15e69e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import classNames from "classnames"
*/
const Constraint = ({ constraint }) => {
const isPattern = /^matches /.test(constraint)
const isStringRange = /characters/.test(constraint)
const isStringRelated = isPattern || isStringRange
const isStringRange = /characters$/.test(constraint)
const isContentMediaType = /^media type: /
const isStringRelated = isPattern || isStringRange || isContentMediaType

return (
<span
Expand Down
5 changes: 5 additions & 0 deletions src/core/plugins/json-schema-2020-12/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ export const stringifyConstraints = (schema) => {
)
if (objectRange !== null) constraints.push(objectRange)

// a Vocabulary for the Contents of String-Encoded Data
if (schema?.contentMediaType) {
constraints.push(`media type: ${schema.contentMediaType}`)
}

return constraints
}

Expand Down

0 comments on commit c15e69e

Please sign in to comment.