ng-openapi 0.0.20 → 0.0.22
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.
- package/README.md +1 -1
- package/cli.cjs +7 -0
- package/index.d.ts +1 -0
- package/index.js +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<h1 align="center"><img src="https://raw.githubusercontent.com/ng-openapi/ng-openapi/HEAD/docs/public/ng-openapi-logo.svg" alt="Logo" style="height: 12vh; margin-bottom: 2vh;
|
|
2
|
+
<h1 align="center"><img src="https://raw.githubusercontent.com/ng-openapi/ng-openapi/HEAD/docs/public/ng-openapi-logo.svg" alt="Logo" style="height: 12vh; margin-bottom: 2vh;" width="160"></h1>
|
|
3
3
|
<h1 align="center"><b>Angular OpenAPI Client Generator</b></h1>
|
|
4
4
|
<p align="center">💪 Made with ❤️ by Angular Devs for Angular Devs</p>
|
|
5
5
|
</div>
|
package/cli.cjs
CHANGED
|
@@ -799,6 +799,9 @@ function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, c
|
|
|
799
799
|
}
|
|
800
800
|
switch (schema.type) {
|
|
801
801
|
case "string":
|
|
802
|
+
if (schema.enum) {
|
|
803
|
+
return schema.enum.map((value) => typeof value === "string" ? `'${escapeString(value)}'` : String(value)).join(" | ");
|
|
804
|
+
}
|
|
802
805
|
if (schema.format === "date" || schema.format === "date-time") {
|
|
803
806
|
const dateType = config.options.dateType === "Date" ? "Date" : "string";
|
|
804
807
|
return nullableType(dateType, nullable);
|
|
@@ -830,6 +833,10 @@ function nullableType(type, isNullable) {
|
|
|
830
833
|
return type + (isNullable ? " | null" : "");
|
|
831
834
|
}
|
|
832
835
|
__name(nullableType, "nullableType");
|
|
836
|
+
function escapeString(str) {
|
|
837
|
+
return str.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
838
|
+
}
|
|
839
|
+
__name(escapeString, "escapeString");
|
|
833
840
|
|
|
834
841
|
// src/lib/generators/service/service-method/service-method-body.generator.ts
|
|
835
842
|
var ServiceMethodBodyGenerator = class {
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -838,6 +838,9 @@ function getTypeScriptType(schemaOrType, config, formatOrNullable, isNullable, c
|
|
|
838
838
|
}
|
|
839
839
|
switch (schema.type) {
|
|
840
840
|
case "string":
|
|
841
|
+
if (schema.enum) {
|
|
842
|
+
return schema.enum.map((value) => typeof value === "string" ? `'${escapeString(value)}'` : String(value)).join(" | ");
|
|
843
|
+
}
|
|
841
844
|
if (schema.format === "date" || schema.format === "date-time") {
|
|
842
845
|
const dateType = config.options.dateType === "Date" ? "Date" : "string";
|
|
843
846
|
return nullableType(dateType, nullable);
|
|
@@ -869,6 +872,10 @@ function nullableType(type, isNullable) {
|
|
|
869
872
|
return type + (isNullable ? " | null" : "");
|
|
870
873
|
}
|
|
871
874
|
__name(nullableType, "nullableType");
|
|
875
|
+
function escapeString(str) {
|
|
876
|
+
return str.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
877
|
+
}
|
|
878
|
+
__name(escapeString, "escapeString");
|
|
872
879
|
|
|
873
880
|
// src/lib/generators/service/service-method/service-method-body.generator.ts
|
|
874
881
|
var _ServiceMethodBodyGenerator = class _ServiceMethodBodyGenerator {
|