@devlearning/swagger-generator 0.0.33 → 0.0.34

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/generator.js CHANGED
@@ -64,16 +64,18 @@ ${API_POST}`, { flag: 'w' });
64
64
  if (apiName == "/api/v{version}/TicketFile/Create") {
65
65
  debugger;
66
66
  }
67
- let parametersRefType = swaggerMethodInfo.parameters.filter(x => x.in == 'query' && x.schema?.$ref != null).map(x => x.schema.$ref.replace('#/components/schemas/', ''));
68
- usedTypes = usedTypes.concat(parametersRefType);
69
- if (swaggerMethodInfo.responses[200].content[contentTypeApplicationJson]?.schema.$ref != null) {
70
- usedTypes.push(swaggerMethodInfo.responses[200].content[contentTypeApplicationJson].schema.$ref.replace('#/components/schemas/', ''));
71
- }
72
- if (swaggerMethodInfo.requestBody?.content[contentTypeApplicationJson]?.schema?.$ref) {
73
- usedTypes.push(swaggerMethodInfo.requestBody?.content[contentTypeApplicationJson]?.schema?.$ref.replace('#/components/schemas/', ''));
74
- }
75
- if (swaggerMethodInfo.requestBody?.content[contentTypeMultipartFormData]?.schema != null) {
76
- usedMultiPart.push(apiName);
67
+ let parametersRefType = swaggerMethodInfo.parameters?.filter(x => x.in == 'query' && x.schema?.$ref != null).map(x => x.schema.$ref.replace('#/components/schemas/', ''));
68
+ if (parametersRefType) {
69
+ usedTypes = usedTypes.concat(parametersRefType);
70
+ if (swaggerMethodInfo.responses[200].content[contentTypeApplicationJson]?.schema.$ref != null) {
71
+ usedTypes.push(swaggerMethodInfo.responses[200].content[contentTypeApplicationJson].schema.$ref.replace('#/components/schemas/', ''));
72
+ }
73
+ if (swaggerMethodInfo.requestBody?.content[contentTypeApplicationJson]?.schema?.$ref) {
74
+ usedTypes.push(swaggerMethodInfo.requestBody?.content[contentTypeApplicationJson]?.schema?.$ref.replace('#/components/schemas/', ''));
75
+ }
76
+ if (swaggerMethodInfo.requestBody?.content[contentTypeMultipartFormData]?.schema != null) {
77
+ usedMultiPart.push(apiName);
78
+ }
77
79
  }
78
80
  }
79
81
  this.retrieveNestedObjects(usedTypes);
@@ -133,7 +135,7 @@ ${MODEL_POST}`, { flag: 'w' });
133
135
  return `request: Models.${swaggerMethodInfo.requestBody.content[contentTypeApplicationJson].schema.$ref.replace('#/components/schemas/', '')}`;
134
136
  }
135
137
  let parameters = ``;
136
- swaggerMethodInfo.parameters.filter(x => x.in == 'query').forEach(parameter => {
138
+ swaggerMethodInfo.parameters?.filter(x => x.in == 'query').forEach(parameter => {
137
139
  if (parameter.schema.$ref != null) {
138
140
  parameters += `${this.toFirstLetterLowercase(parameter.name)}: Models.${parameter.schema.$ref.replace('#/components/schemas/', '')}, `;
139
141
  }
@@ -151,7 +153,7 @@ ${MODEL_POST}`, { flag: 'w' });
151
153
  retrieveQueryParametersDeclaration(swaggerMethodInfo) {
152
154
  if (swaggerMethodInfo.requestBody != null)
153
155
  return ``;
154
- let filteredParameters = swaggerMethodInfo.parameters.filter(x => x.in == 'query');
156
+ let filteredParameters = swaggerMethodInfo.parameters?.filter(x => x.in == 'query');
155
157
  if (filteredParameters.length == 0)
156
158
  return ``;
157
159
  let parameters = ``;
@@ -198,7 +200,7 @@ ${MODEL_POST}`, { flag: 'w' });
198
200
  retrieveQueryParameters(swaggerMethodInfo) {
199
201
  if (swaggerMethodInfo.requestBody != null)
200
202
  return ``;
201
- let filteredParameters = swaggerMethodInfo.parameters.filter(x => x.in == 'query');
203
+ let filteredParameters = swaggerMethodInfo.parameters?.filter(x => x.in == 'query');
202
204
  if (filteredParameters.length == 0)
203
205
  return ``;
204
206
  let parameters = `?`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devlearning/swagger-generator",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/generator.ts CHANGED
@@ -78,23 +78,25 @@ ${API_POST}`,
78
78
  const method = Object.getOwnPropertyNames(swaggerMethod)[0];
79
79
  const swaggerMethodInfo = swaggerMethod[method];
80
80
 
81
- if(apiName == "/api/v{version}/TicketFile/Create"){
82
- debugger
81
+ if (apiName == "/api/v{version}/TicketFile/Create") {
82
+ debugger
83
83
  }
84
84
 
85
- let parametersRefType = swaggerMethodInfo.parameters.filter(x => x.in == 'query' && x.schema?.$ref != null).map(x => x.schema.$ref.replace('#/components/schemas/', ''))
86
- usedTypes = usedTypes.concat(parametersRefType);
85
+ let parametersRefType = swaggerMethodInfo.parameters?.filter(x => x.in == 'query' && x.schema?.$ref != null).map(x => x.schema.$ref.replace('#/components/schemas/', ''))
86
+ if (parametersRefType) {
87
+ usedTypes = usedTypes.concat(parametersRefType);
87
88
 
88
- if (swaggerMethodInfo.responses[200].content[contentTypeApplicationJson]?.schema.$ref != null) {
89
- usedTypes.push(swaggerMethodInfo.responses[200].content[contentTypeApplicationJson].schema.$ref.replace('#/components/schemas/', ''));
90
- }
89
+ if (swaggerMethodInfo.responses[200].content[contentTypeApplicationJson]?.schema.$ref != null) {
90
+ usedTypes.push(swaggerMethodInfo.responses[200].content[contentTypeApplicationJson].schema.$ref.replace('#/components/schemas/', ''));
91
+ }
91
92
 
92
- if (swaggerMethodInfo.requestBody?.content[contentTypeApplicationJson]?.schema?.$ref) {
93
- usedTypes.push(swaggerMethodInfo.requestBody?.content[contentTypeApplicationJson]?.schema?.$ref.replace('#/components/schemas/', ''));
94
- }
93
+ if (swaggerMethodInfo.requestBody?.content[contentTypeApplicationJson]?.schema?.$ref) {
94
+ usedTypes.push(swaggerMethodInfo.requestBody?.content[contentTypeApplicationJson]?.schema?.$ref.replace('#/components/schemas/', ''));
95
+ }
95
96
 
96
- if (swaggerMethodInfo.requestBody?.content[contentTypeMultipartFormData]?.schema != null) {
97
- usedMultiPart.push(apiName);
97
+ if (swaggerMethodInfo.requestBody?.content[contentTypeMultipartFormData]?.schema != null) {
98
+ usedMultiPart.push(apiName);
99
+ }
98
100
  }
99
101
  }
100
102
 
@@ -169,7 +171,7 @@ ${MODEL_POST}`,
169
171
  }
170
172
 
171
173
  let parameters = ``;
172
- swaggerMethodInfo.parameters.filter(x => x.in == 'query').forEach(parameter => {
174
+ swaggerMethodInfo.parameters?.filter(x => x.in == 'query').forEach(parameter => {
173
175
  if (parameter.schema.$ref != null) {
174
176
  parameters += `${this.toFirstLetterLowercase(parameter.name)}: Models.${parameter.schema.$ref.replace('#/components/schemas/', '')}, `;
175
177
  } else {
@@ -189,7 +191,7 @@ ${MODEL_POST}`,
189
191
  retrieveQueryParametersDeclaration(swaggerMethodInfo: SwaggerMethod) {
190
192
  if (swaggerMethodInfo.requestBody != null) return ``;
191
193
 
192
- let filteredParameters = swaggerMethodInfo.parameters.filter(x => x.in == 'query');
194
+ let filteredParameters = swaggerMethodInfo.parameters?.filter(x => x.in == 'query');
193
195
  if (filteredParameters.length == 0) return ``;
194
196
 
195
197
  let parameters = ``;
@@ -235,7 +237,7 @@ ${MODEL_POST}`,
235
237
  retrieveQueryParameters(swaggerMethodInfo: SwaggerMethod) {
236
238
  if (swaggerMethodInfo.requestBody != null) return ``;
237
239
 
238
- let filteredParameters = swaggerMethodInfo.parameters.filter(x => x.in == 'query');
240
+ let filteredParameters = swaggerMethodInfo.parameters?.filter(x => x.in == 'query');
239
241
  if (filteredParameters.length == 0) return ``;
240
242
 
241
243
  let parameters = `?`;