Skip to content

Commit

Permalink
Add Class Name before parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
faizanvahevaria committed Jun 20, 2019
1 parent c64d92f commit 39f4f87
Showing 1 changed file with 35 additions and 43 deletions.
78 changes: 35 additions & 43 deletions openApi-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,34 @@ class OpenApiGenerator {
}
}

let arrAssoc = [];

let assocClassLink = classLink.filter(item => {
return item.associationSide.end1.reference._id==objClass._id;
});

/**
* Add asscociation class Properties
* eg.
* TransportMeansParty
allOf:
- $ref: '#/components/schemas/TransportPartyIds'
- $ref: '#/components/schemas/TransportMeansParty'
- type: object
*/
if (assocClassLink.length > 0) {
assocClassLink.forEach(item => {
this.writeAssociationClassProperties(codeWriter, item);

})
}


let arrGeneral = this.findGeneralizationOfClass(objClass); // Git issue #12

let arrAssoc = [];



let aggregationClasses = [];

let classAssociations = this.findAssociationOfClass(objClass);
Expand All @@ -294,11 +318,17 @@ class OpenApiGenerator {
// for (i = 0, len = objClass.ownedElements.length; i < len; i++) {
// let assoc = objClass.ownedElements[i];
if (assoc instanceof type.UMLAssociation) {

let filterAssoc = arrAssoc.filter(item=>{
return item.name==assoc.name;
});



if(filterAssoc.length==0 && assoc.name!="" && !flagNoName){



if(assoc.end1.aggregation=="shared"){
// this.writeAssociationProperties(codeWriter,assoc);
aggregationClasses.push(assoc.end2.reference);
Expand Down Expand Up @@ -354,24 +384,7 @@ class OpenApiGenerator {
}
});

let assocClassLink = classLink.filter(item => {
return item.associationSide.end1.reference._id==objClass._id;
});

/**
* Add asscociation class Properties
* eg.
* TransportMeansParty
allOf:
- $ref: '#/components/schemas/TransportPartyIds'
- $ref: '#/components/schemas/TransportMeansParty'
- type: object
*/
if (assocClassLink.length > 0) {
assocClassLink.forEach(item => {
this.writeAssociationClassProperties(codeWriter, item);
})
}


codeWriter.outdent();

Expand Down Expand Up @@ -1218,32 +1231,11 @@ class OpenApiGenerator {
? this.buildDescription(itemParameters.documentation)
: "missing description"), false, "{type: string}");
} else {

let param = itemParameters.type.attributes.filter(item => {
return itemParameters.name.toUpperCase() == item.name.toUpperCase();
});

if (param.length == 0) {
let generalizeClasses = this.findGeneralizationOfClass(itemParameters.type);
console.log(generalizeClasses);
param = generalizeClasses[0].target.attributes.filter(item => {
return itemParameters.name.toUpperCase() == item.name.toUpperCase();
});
}

if (param[0].type == "DateTime") {
this.buildParameter(codeWriter, "before_" + param[0].name, "query", (itemParameters.documentation
? this.buildDescription(itemParameters.documentation)
: "missing description"), false, "{type: string}");
this.buildParameter(codeWriter, "after_" + param[0].name, "query", (itemParameters.documentation
? this.buildDescription(itemParameters.documentation)
: "missing description"), false, "{type: string}");

} else {
this.buildParameter(codeWriter, param[0].name, "query", (itemParameters.documentation

this.buildParameter(codeWriter, itemParameters.type.name+"."+itemParameters.name, "query", (itemParameters.documentation
? this.buildDescription(itemParameters.documentation)
: "missing description"), false, "{type: string}");
}


}
}
Expand Down

0 comments on commit 39f4f87

Please sign in to comment.