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 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; max-width: 99%"></h1>
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
@@ -21,6 +21,7 @@ interface TypeSchema {
21
21
  $ref?: string;
22
22
  items?: any;
23
23
  nullable?: boolean;
24
+ enum?: Array<string | number>;
24
25
  [key: string]: any;
25
26
  }
26
27
 
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-openapi",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "Generate Angular services and TypeScript types from OpenAPI/Swagger specifications",
5
5
  "keywords": [
6
6
  "angular",