-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support openapi 3.1 (#122)
- Loading branch information
1 parent
d60cadd
commit 8444461
Showing
15 changed files
with
380 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,44 @@ | ||
export function sampleNumber(schema) { | ||
let res; | ||
if (schema.maximum && schema.minimum) { | ||
res = schema.exclusiveMinimum ? Math.floor(schema.minimum) + 1 : schema.minimum; | ||
if ((schema.exclusiveMaximum && res >= schema.maximum) || | ||
((!schema.exclusiveMaximum && res > schema.maximum))) { | ||
res = (schema.maximum + schema.minimum) / 2; | ||
let res = 0; | ||
if (typeof schema.exclusiveMinimum === 'boolean' || typeof schema.exclusiveMaximum === 'boolean') { //legacy support for jsonschema draft 4 of exclusiveMaximum/exclusiveMinimum as booleans | ||
if (schema.maximum && schema.minimum) { | ||
res = schema.exclusiveMinimum ? Math.floor(schema.minimum) + 1 : schema.minimum; | ||
if ((schema.exclusiveMaximum && res >= schema.maximum) || | ||
((!schema.exclusiveMaximum && res > schema.maximum))) { | ||
res = (schema.maximum + schema.minimum) / 2; | ||
} | ||
return res; | ||
} | ||
return res; | ||
} | ||
if (schema.minimum) { | ||
if (schema.exclusiveMinimum) { | ||
return Math.floor(schema.minimum) + 1; | ||
} else { | ||
if (schema.minimum) { | ||
if (schema.exclusiveMinimum) { | ||
return Math.floor(schema.minimum) + 1; | ||
} else { | ||
return schema.minimum; | ||
} | ||
} | ||
if (schema.maximum) { | ||
if (schema.exclusiveMaximum) { | ||
return (schema.maximum > 0) ? 0 : Math.floor(schema.maximum) - 1; | ||
} else { | ||
return (schema.maximum > 0) ? 0 : schema.maximum; | ||
} | ||
} | ||
} else { | ||
if (schema.minimum) { | ||
return schema.minimum; | ||
} | ||
} | ||
if (schema.maximum) { | ||
if (schema.exclusiveMaximum) { | ||
return (schema.maximum > 0) ? 0 : Math.floor(schema.maximum) - 1; | ||
} else { | ||
return (schema.maximum > 0) ? 0 : schema.maximum; | ||
if (schema.exclusiveMinimum) { | ||
res = Math.floor(schema.exclusiveMinimum) + 1; | ||
|
||
if (res === schema.exclusiveMaximum) { | ||
res = (res + Math.floor(schema.exclusiveMaximum) - 1) / 2; | ||
} | ||
} else if (schema.exclusiveMaximum) { | ||
res = Math.floor(schema.exclusiveMaximum) - 1; | ||
} else if (schema.maximum) { | ||
res = schema.maximum; | ||
} | ||
} | ||
|
||
return 0; | ||
return res; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { JSONSchema7 } from 'json-schema'; | ||
|
||
export interface Options { | ||
readonly skipNonRequired?: boolean; | ||
readonly skipReadOnly?: boolean; | ||
readonly skipWriteOnly?: boolean; | ||
readonly quiet?: boolean; | ||
} | ||
|
||
export function sample(schema: JSONSchema7, options?: Options, document?: object): unknown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.