Skip to content

Commit dde25a2

Browse files
tm1000MikeRalphson
authored andcommitted
resolve issues with responses loops not working and dataType (#72)
* resolve issues with responses loops not working and dataType * Update adaptor.js
1 parent 4060a4f commit dde25a2

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.formatOnSave": false
3+
}

adaptor.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,6 @@ function convertOperation(op,verb,path,pathItem,obj,api) {
144144
operation.path = path;
145145
operation.replacedPathName = path; //?
146146

147-
operation.operationId = op.operationId||('operation'+obj.openapi.operationCounter++);
148-
operation.operationIdLowerCase = operation.operationId.toLowerCase();
149-
operation.operationIdSnakeCase = Case.snake(operation.operationId);
150-
operation.nickname = operation.operationId;
151-
//operation.classname = obj.classPrefix+operation.nickname;
152-
153147
operation.description = op.description;
154148
operation.summary = op.summary;
155149
operation.allParams = [];
@@ -188,6 +182,7 @@ function convertOperation(op,verb,path,pathItem,obj,api) {
188182
let effParameters = (op.parameters||[]).concat(pathItem.parameters||[]);
189183
effParameters = effParameters.filter((param, index, self) => self.findIndex((p) => {return p.name === param.name && p.in === param.in; }) === index);
190184

185+
const paramList = [];
191186
for (let pa in effParameters) {
192187
operation.hasParams = true;
193188
let param = effParameters[pa];
@@ -199,6 +194,7 @@ function convertOperation(op,verb,path,pathItem,obj,api) {
199194
parameter.isFormParam = false;
200195
parameter.paramName = param.name;
201196
parameter.baseName = param.name;
197+
paramList.push(param.name);
202198
parameter.required = param.required||false;
203199
parameter.optional = !parameter.required;
204200
if (parameter.required) operation.hasRequiredParams = true;
@@ -267,6 +263,11 @@ function convertOperation(op,verb,path,pathItem,obj,api) {
267263
}*/
268264
} // end of effective parameters
269265

266+
operation.operationId = op.operationId || Case.camel(op.tags[0] + (paramList ? '_' + paramList.join('_') + '_' : '') + verb);
267+
operation.operationIdLowerCase = operation.operationId.toLowerCase();
268+
operation.operationIdSnakeCase = Case.snake(operation.operationId);
269+
operation.nickname = operation.operationId;
270+
270271
operation.bodyParams = [];
271272
if (op.requestBody) {
272273
operation.openapi.requestBody = op.requestBody;
@@ -401,6 +402,7 @@ function convertOperation(op,verb,path,pathItem,obj,api) {
401402
entry.openapi = {};
402403
entry.openapi.links = response.links;
403404
operation.responses.push(entry);
405+
operation.responses = convertArray(operation.responses);
404406
}
405407

406408
if (obj.sortParamsByRequiredFlag) {
@@ -930,7 +932,8 @@ function transform(api, defaults, callback) {
930932
entry.isNotRequired = !entry.required;
931933
entry.readOnly = !!schema.readOnly;
932934
entry.type = typeMap(entry.type,entry.required,schema);
933-
entry.datatype = entry.type; //?
935+
entry.dataType = entry.type; //camelCase for imported files
936+
entry.datatype = entry.type; //lower for other files
934937
entry.jsonSchema = safeJson(schema,null,2);
935938
for (let p in schemaProperties) {
936939
if (typeof schema[p] !== 'undefined') entry[p] = schema[p];

templates/r/namespace.mustache

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Generated by swagger-codegen: https://github.com/swagger-api/swagger-codegen
2+
# Do not edit by hand
3+
4+
{{#models}}
5+
{{#model}}
6+
export({{{classname}}})
7+
{{/model}}
8+
{{/models}}

0 commit comments

Comments
 (0)