fix(json-schema-2020-12): custom OAS 3.1 formats in type inferrence (#8912)
This commit is contained in:
@@ -70,13 +70,12 @@ export const getType = (schema, processedSchemas = new WeakSet()) => {
|
|||||||
Object.hasOwn(schema, "patternProperties")
|
Object.hasOwn(schema, "patternProperties")
|
||||||
) {
|
) {
|
||||||
return "object"
|
return "object"
|
||||||
} else if (
|
} else if (["int32", "int64"].includes(schema.format)) {
|
||||||
Object.hasOwn(schema, "pattern") ||
|
// OpenAPI 3.1.0 integer custom formats
|
||||||
Object.hasOwn(schema, "format") ||
|
return "integer"
|
||||||
Object.hasOwn(schema, "minLength") ||
|
} else if (["float", "double"].includes(schema.format)) {
|
||||||
Object.hasOwn(schema, "maxLength")
|
// OpenAPI 3.1.0 number custom formats
|
||||||
) {
|
return "number"
|
||||||
return "string"
|
|
||||||
} else if (
|
} else if (
|
||||||
Object.hasOwn(schema, "minimum") ||
|
Object.hasOwn(schema, "minimum") ||
|
||||||
Object.hasOwn(schema, "maximum") ||
|
Object.hasOwn(schema, "maximum") ||
|
||||||
@@ -85,6 +84,13 @@ export const getType = (schema, processedSchemas = new WeakSet()) => {
|
|||||||
Object.hasOwn(schema, "multipleOf")
|
Object.hasOwn(schema, "multipleOf")
|
||||||
) {
|
) {
|
||||||
return "number | integer"
|
return "number | integer"
|
||||||
|
} else if (
|
||||||
|
Object.hasOwn(schema, "pattern") ||
|
||||||
|
Object.hasOwn(schema, "format") ||
|
||||||
|
Object.hasOwn(schema, "minLength") ||
|
||||||
|
Object.hasOwn(schema, "maxLength")
|
||||||
|
) {
|
||||||
|
return "string"
|
||||||
} else if (typeof schema.const !== "undefined") {
|
} else if (typeof schema.const !== "undefined") {
|
||||||
if (schema.const === null) {
|
if (schema.const === null) {
|
||||||
return "null"
|
return "null"
|
||||||
|
|||||||
Reference in New Issue
Block a user