add min max for prompting
This commit is contained in:
Родитель
785bee123a
Коммит
c06d92826e
|
@ -164,8 +164,10 @@ export async function expandPropertyDefinition(property: any, templateDirs: stri
|
|||
return schema
|
||||
}
|
||||
|
||||
// Items keywords that are constraints and can be promoted to the property level
|
||||
const ContraintKeywords = ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'pattern']
|
||||
/**
|
||||
* Promote any $properties in items to the parent property unless already specified.
|
||||
* Promote any $properties or constraints in items to the parent property unless already specified.
|
||||
* This makes it easier to use a child schema in items.
|
||||
* @param schema Schema fragment to promote.
|
||||
*/
|
||||
|
@ -177,9 +179,11 @@ function promoteItems(schema: any): void {
|
|||
} else if (typeof schema === 'object' && schema !== null) {
|
||||
for (var [prop, val] of Object.entries(schema)) {
|
||||
if (prop === 'items') {
|
||||
for (var [prop, itemVal] of Object.entries(val as object)) {
|
||||
if (prop.startsWith('$') && prop !== '$schema' && !schema[prop]) {
|
||||
schema[prop] = itemVal
|
||||
if (val && typeof val === 'object' && !Array.isArray(val)) {
|
||||
for (var [prop, itemVal] of Object.entries(val as object)) {
|
||||
if (((prop.startsWith('$') && prop !== '$schema') || ContraintKeywords.includes(prop)) && !schema[prop]) {
|
||||
schema[prop] = itemVal
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
[generator.lg](../generator.lg)
|
||||
|
||||
# filename
|
||||
- ${addFilename('age')}
|
||||
|
||||
# template
|
||||
- ${addWithUnits('age')}
|
|
@ -1,8 +0,0 @@
|
|||
[generator.lg](../generator.lg)
|
||||
|
||||
# filename
|
||||
- ${removeFilename('age')}
|
||||
|
||||
# template
|
||||
- ${removeValueOrArrayDialog('age')}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
[generator.lg](../generator.lg)
|
||||
|
||||
# filename
|
||||
- ${addFilename('dimension')}
|
||||
|
||||
# template
|
||||
- ${addWithUnits('dimension')}
|
|
@ -1,8 +0,0 @@
|
|||
[generator.lg](../generator.lg)
|
||||
|
||||
# filename
|
||||
- ${removeFilename('dimension')}
|
||||
|
||||
# template
|
||||
- ${removeValueOrArrayDialog('dimension')}
|
||||
|
|
@ -131,12 +131,6 @@ ${'#'} ${type}Entity_Value(entity)
|
|||
|
||||
>> Units
|
||||
# unitsTemplates(type)
|
||||
- IF: ${propertySchema.minimum || propertySchema.maximum}
|
||||
- ${unitsTemplatesWithoutMinMax(type)} ${validationTemplatesWithMinMax()}
|
||||
- ELSE:
|
||||
- ${unitsTemplatesWithoutMinMax(type)}
|
||||
|
||||
# unitsTemplatesWithoutMinMax(type)
|
||||
- ```${formImport('form.en-us.lg')}
|
||||
${promptTemplates(missingDefault(type), changeDefault(type))}
|
||||
${confirmationTemplates(expectedSetDefault(),
|
||||
|
@ -145,6 +139,7 @@ ${confirmationTemplates(expectedSetDefault(),
|
|||
unexpectedUpdateDefault(),
|
||||
removeDefault(),
|
||||
clearDefault())}
|
||||
${validationTemplatesWithMinMax()}
|
||||
${incorrectUnitsTemplate()}
|
||||
${helpTemplates(repromptDefault(type), helpDefault(type))}
|
||||
${showTemplate(showDefault())}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
[generator.lg](../generator.lg)
|
||||
|
||||
# filename
|
||||
- ${addFilename('money')}
|
||||
|
||||
# template
|
||||
- ${addWithUnits('money')}
|
|
@ -1,7 +0,0 @@
|
|||
[generator.lg](../generator.lg)
|
||||
|
||||
# filename
|
||||
- ${removeFilename('money')}
|
||||
|
||||
# template
|
||||
- ${removeValueOrArrayDialog('money')}
|
|
@ -1,7 +0,0 @@
|
|||
[generator.lg](../generator.lg)
|
||||
|
||||
# filename
|
||||
- ${addFilename('temperature')}
|
||||
|
||||
# template
|
||||
- ${addWithUnits('temperature')}
|
|
@ -1,8 +0,0 @@
|
|||
[generator.lg](../generator.lg)
|
||||
|
||||
# filename
|
||||
- ${removeFilename('temperature')}
|
||||
|
||||
# template
|
||||
- ${removeValueOrArrayDialog('temperature')}
|
||||
|
Загрузка…
Ссылка в новой задаче