@penkov/swagger-code-gen 1.8.4 → 1.8.6

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/dist/property.js CHANGED
@@ -95,11 +95,16 @@ export class Property {
95
95
  }
96
96
  static toJsType(tpe, itemTpe = 'any', format = none) {
97
97
  switch (tpe) {
98
- case 'boolean': return 'boolean';
99
- case 'number': return 'number';
100
- case 'integer': return 'number';
101
- case 'file': return 'File';
102
- case 'any': return 'any';
98
+ case 'boolean':
99
+ return 'boolean';
100
+ case 'number':
101
+ return 'number';
102
+ case 'integer':
103
+ return 'number';
104
+ case 'file':
105
+ return 'File';
106
+ case 'any':
107
+ return 'any';
103
108
  case 'string':
104
109
  if (format.contains('binary')) {
105
110
  return 'Blob | Buffer';
@@ -107,8 +112,10 @@ export class Property {
107
112
  else {
108
113
  return 'string';
109
114
  }
110
- case 'array': return `ReadonlyArray<${Property.toJsType(itemTpe)}>`;
111
- default: return NameUtils.normaliseClassname(tpe);
115
+ case 'array':
116
+ return `ReadonlyArray<${Property.toJsType(itemTpe)}>`;
117
+ default:
118
+ return NameUtils.normaliseClassname(tpe);
112
119
  }
113
120
  }
114
121
  get normalType() {
package/dist/schemas.js CHANGED
@@ -58,16 +58,17 @@ export class SchemaFactory {
58
58
  }
59
59
  }
60
60
  export class SchemaEnum {
61
- constructor(name, title, type, defaultValue, values) {
61
+ constructor(name, title, description, type, defaultValue, values) {
62
62
  this.name = name;
63
63
  this.title = title;
64
+ this.description = description;
64
65
  this.type = type;
65
66
  this.defaultValue = defaultValue;
66
67
  this.values = values;
67
68
  this.schemaType = 'enum';
68
69
  }
69
70
  static fromDefinition(name, def) {
70
- return new SchemaEnum(name, def.title, def.type, option(def.default), option(def.enum).map(Collection.from).getOrElseValue(Nil));
71
+ return new SchemaEnum(name, def.title, option(def.description), def.type, option(def.default), option(def.enum).map(Collection.from).getOrElseValue(Nil));
71
72
  }
72
73
  }
73
74
  export class SchemaObject {
@@ -1,6 +1,11 @@
1
1
  <%_ if (schema.schemaType === 'object') { -%>
2
2
  export class <%= schema.normalName %>Dto {
3
3
 
4
+ /**
5
+ <%_ schema.properties.foreach(p => { -%>
6
+ * @param <%= p.name %> <%- p.description.getOrElseValue('') %>
7
+ <%_ }); -%>
8
+ */
4
9
  constructor(
5
10
  <%_ schema.properties.foreach(p => { -%>
6
11
  readonly <%= p.name %>: <%- p.scatsWrapperType %>,
@@ -1,11 +1,21 @@
1
1
  <%_ if (schema.schemaType === 'object') { -%>
2
2
  export interface <%= schema.normalName %> {
3
3
  <%_ schema.properties.foreach(p => { -%>
4
+ <%_ p.description.foreach(d => { -%>
5
+ /**
6
+ * <%= d %>
7
+ */
8
+ <%_ }); -%>
4
9
  readonly <%= p.name %><%= !p.required ? '?' : '' %>: <%- p.jsType %>;
5
10
  <%_ }); -%>
6
11
  }
7
12
  <%_ } if (schema.schemaType === 'enum') { -%>
8
- export enum <%= schema.normalName %> {
13
+ <%_ schema.description.foreach(d => { -%>
14
+ /**
15
+ * <%= d %>
16
+ */
17
+ <%_ }); -%>
18
+ export enum <%= schema.name %> {
9
19
  <%_ schema.values.foreach(p => { -%>
10
20
  <%= p %> = '<%= p %>',
11
21
  <%_ }); -%>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@penkov/swagger-code-gen",
3
- "version": "1.8.4",
3
+ "version": "1.8.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "generate-client": "./dist/cli.mjs"