@ng-forge/openapi-generator 0.8.0-next.5 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -454,6 +454,7 @@ var logger = {
|
|
|
454
454
|
|
|
455
455
|
// packages/openapi-generator/src/mapper/schema-to-fields.ts
|
|
456
456
|
var NULLABLE_SUPPORTED_FIELD_TYPES = /* @__PURE__ */ new Set(["input", "textarea", "select", "radio", "multi-checkbox", "slider", "datepicker"]);
|
|
457
|
+
var CONTAINER_FIELD_TYPES = /* @__PURE__ */ new Set(["group", "array", "row", "page", "container"]);
|
|
457
458
|
function singularize(label) {
|
|
458
459
|
if (label.length >= 4 && label.endsWith("s") && !label.endsWith("ss")) {
|
|
459
460
|
return label.slice(0, -1);
|
|
@@ -481,7 +482,6 @@ function mapSchemaToFields(schema, requiredFields, options = {}) {
|
|
|
481
482
|
fields2.push({
|
|
482
483
|
key: `${group.discriminatorValue}Variant`,
|
|
483
484
|
type: "group",
|
|
484
|
-
label: toEnumLabel(group.discriminatorValue),
|
|
485
485
|
fields: variantFields,
|
|
486
486
|
logic: [
|
|
487
487
|
{
|
|
@@ -526,7 +526,6 @@ function mapPropertyToField(prop, options, ambiguousFields, warnings) {
|
|
|
526
526
|
return {
|
|
527
527
|
key: prop.name,
|
|
528
528
|
type: "group",
|
|
529
|
-
label: prop.schema["title"] ?? toLabel(prop.name),
|
|
530
529
|
fields: innerResult.fields
|
|
531
530
|
};
|
|
532
531
|
}
|
|
@@ -562,9 +561,11 @@ function mapPropertyToField(prop, options, ambiguousFields, warnings) {
|
|
|
562
561
|
}
|
|
563
562
|
const field = {
|
|
564
563
|
key: prop.name,
|
|
565
|
-
type: finalType
|
|
566
|
-
label: prop.schema["title"] ?? toLabel(prop.name)
|
|
564
|
+
type: finalType
|
|
567
565
|
};
|
|
566
|
+
if (!CONTAINER_FIELD_TYPES.has(finalType)) {
|
|
567
|
+
field.label = prop.schema["title"] ?? toLabel(prop.name);
|
|
568
|
+
}
|
|
568
569
|
if (prop.schema["readOnly"]) {
|
|
569
570
|
field.disabled = true;
|
|
570
571
|
logger.verbose(`Field '${fieldPath}': disabled (readOnly in schema)`);
|
|
@@ -647,9 +648,11 @@ function mapPropertyToField(prop, options, ambiguousFields, warnings) {
|
|
|
647
648
|
const itemTypeResult = mapSchemaToFieldType(items);
|
|
648
649
|
const templateField = {
|
|
649
650
|
key: "value",
|
|
650
|
-
type: itemTypeResult.fieldType
|
|
651
|
-
label: fieldLabel
|
|
651
|
+
type: itemTypeResult.fieldType
|
|
652
652
|
};
|
|
653
|
+
if (!CONTAINER_FIELD_TYPES.has(itemTypeResult.fieldType)) {
|
|
654
|
+
templateField.label = fieldLabel;
|
|
655
|
+
}
|
|
653
656
|
if (itemTypeResult.props && Object.keys(itemTypeResult.props).length > 0) {
|
|
654
657
|
templateField.props = itemTypeResult.props;
|
|
655
658
|
}
|
|
@@ -704,7 +707,9 @@ function generateFieldLines(field, indent) {
|
|
|
704
707
|
lines.push(`${indent}{`);
|
|
705
708
|
lines.push(`${indent} key: '${escapeString(field.key)}',`);
|
|
706
709
|
lines.push(`${indent} type: '${escapeString(field.type)}',`);
|
|
707
|
-
|
|
710
|
+
if (field.label !== void 0) {
|
|
711
|
+
lines.push(`${indent} label: '${escapeString(field.label)}',`);
|
|
712
|
+
}
|
|
708
713
|
if (field.value !== void 0) {
|
|
709
714
|
lines.push(`${indent} value: ${JSON.stringify(field.value)},`);
|
|
710
715
|
}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -446,6 +446,7 @@ var logger = {
|
|
|
446
446
|
|
|
447
447
|
// packages/openapi-generator/src/mapper/schema-to-fields.ts
|
|
448
448
|
var NULLABLE_SUPPORTED_FIELD_TYPES = /* @__PURE__ */ new Set(["input", "textarea", "select", "radio", "multi-checkbox", "slider", "datepicker"]);
|
|
449
|
+
var CONTAINER_FIELD_TYPES = /* @__PURE__ */ new Set(["group", "array", "row", "page", "container"]);
|
|
449
450
|
function singularize(label) {
|
|
450
451
|
if (label.length >= 4 && label.endsWith("s") && !label.endsWith("ss")) {
|
|
451
452
|
return label.slice(0, -1);
|
|
@@ -473,7 +474,6 @@ function mapSchemaToFields(schema, requiredFields, options = {}) {
|
|
|
473
474
|
fields2.push({
|
|
474
475
|
key: `${group.discriminatorValue}Variant`,
|
|
475
476
|
type: "group",
|
|
476
|
-
label: toEnumLabel(group.discriminatorValue),
|
|
477
477
|
fields: variantFields,
|
|
478
478
|
logic: [
|
|
479
479
|
{
|
|
@@ -518,7 +518,6 @@ function mapPropertyToField(prop, options, ambiguousFields, warnings) {
|
|
|
518
518
|
return {
|
|
519
519
|
key: prop.name,
|
|
520
520
|
type: "group",
|
|
521
|
-
label: prop.schema["title"] ?? toLabel(prop.name),
|
|
522
521
|
fields: innerResult.fields
|
|
523
522
|
};
|
|
524
523
|
}
|
|
@@ -554,9 +553,11 @@ function mapPropertyToField(prop, options, ambiguousFields, warnings) {
|
|
|
554
553
|
}
|
|
555
554
|
const field = {
|
|
556
555
|
key: prop.name,
|
|
557
|
-
type: finalType
|
|
558
|
-
label: prop.schema["title"] ?? toLabel(prop.name)
|
|
556
|
+
type: finalType
|
|
559
557
|
};
|
|
558
|
+
if (!CONTAINER_FIELD_TYPES.has(finalType)) {
|
|
559
|
+
field.label = prop.schema["title"] ?? toLabel(prop.name);
|
|
560
|
+
}
|
|
560
561
|
if (prop.schema["readOnly"]) {
|
|
561
562
|
field.disabled = true;
|
|
562
563
|
logger.verbose(`Field '${fieldPath}': disabled (readOnly in schema)`);
|
|
@@ -639,9 +640,11 @@ function mapPropertyToField(prop, options, ambiguousFields, warnings) {
|
|
|
639
640
|
const itemTypeResult = mapSchemaToFieldType(items);
|
|
640
641
|
const templateField = {
|
|
641
642
|
key: "value",
|
|
642
|
-
type: itemTypeResult.fieldType
|
|
643
|
-
label: fieldLabel
|
|
643
|
+
type: itemTypeResult.fieldType
|
|
644
644
|
};
|
|
645
|
+
if (!CONTAINER_FIELD_TYPES.has(itemTypeResult.fieldType)) {
|
|
646
|
+
templateField.label = fieldLabel;
|
|
647
|
+
}
|
|
645
648
|
if (itemTypeResult.props && Object.keys(itemTypeResult.props).length > 0) {
|
|
646
649
|
templateField.props = itemTypeResult.props;
|
|
647
650
|
}
|
|
@@ -696,7 +699,9 @@ function generateFieldLines(field, indent) {
|
|
|
696
699
|
lines.push(`${indent}{`);
|
|
697
700
|
lines.push(`${indent} key: '${escapeString(field.key)}',`);
|
|
698
701
|
lines.push(`${indent} type: '${escapeString(field.type)}',`);
|
|
699
|
-
|
|
702
|
+
if (field.label !== void 0) {
|
|
703
|
+
lines.push(`${indent} label: '${escapeString(field.label)}',`);
|
|
704
|
+
}
|
|
700
705
|
if (field.value !== void 0) {
|
|
701
706
|
lines.push(`${indent} value: ${JSON.stringify(field.value)},`);
|
|
702
707
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-to-fields.d.ts","sourceRoot":"","sources":["../../../../../packages/openapi-generator/src/mapper/schema-to-fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,4BAA4B,CAAC;AAG/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"schema-to-fields.d.ts","sourceRoot":"","sources":["../../../../../packages/openapi-generator/src/mapper/schema-to-fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,4BAA4B,CAAC;AAG/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAiC9D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,M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