Skip to content

Commit

Permalink
feat: introduce samples framework for JSON Schema 2020-12
Browse files Browse the repository at this point in the history
Refs #8577
  • Loading branch information
char0n committed May 30, 2023
1 parent 3059a63 commit d186b53
Show file tree
Hide file tree
Showing 6 changed files with 811 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @prettier
*/
import { useFn } from "./hooks"
import { useFn } from "../hooks"

export const upperFirst = (value) => {
if (typeof value === "string") {
Expand Down Expand Up @@ -58,9 +58,13 @@ export const getType = (schema, processedSchemas = new WeakSet()) => {
}

const inferType = () => {
if (prefixItems || items) {
if (prefixItems || items || schema.contains) {
return getArrayType()
} else if (schema.properties || schema.additionalProperties) {
} else if (
schema.properties ||
schema.additionalProperties ||
schema.patternProperties
) {
return "object"
} else if (
schema.pattern ||
Expand All @@ -77,7 +81,7 @@ export const getType = (schema, processedSchemas = new WeakSet()) => {
schema.multipleOf
) {
return "number | integer"
} else if (schema.const !== undefined) {
} else if (typeof schema.const !== "undefined") {
if (schema.const === null) {
return "null"
} else if (typeof schema.const === "boolean") {
Expand Down
Loading

0 comments on commit d186b53

Please sign in to comment.