feat(samples): add support for const keyword (#8884)
This change is specific to JSON Schema 2020-12 and OpenAPI 3.1.0. Refs #8577
This commit is contained in:
@@ -101,6 +101,7 @@ const liftSampleHelper = (oldSchema, target, config = {}) => {
|
||||
"enum",
|
||||
"xml",
|
||||
"type",
|
||||
"const",
|
||||
...objectContracts,
|
||||
...arrayContracts,
|
||||
...numberContracts,
|
||||
@@ -683,7 +684,10 @@ export const sampleFromSchemaGeneric = (
|
||||
}
|
||||
|
||||
let value
|
||||
if (schema && Array.isArray(schema.enum)) {
|
||||
if (typeof schema?.const !== "undefined") {
|
||||
// display const value
|
||||
value = schema.const
|
||||
} else if (schema && Array.isArray(schema.enum)) {
|
||||
//display enum first value
|
||||
value = normalizeArray(schema.enum)[0]
|
||||
} else if (schema) {
|
||||
|
||||
Reference in New Issue
Block a user