Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#120 PUT methods should be more like POST and less like GET #121

Merged
merged 1 commit into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion menus/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"id": "tools.openapi.testallextension",
"command": "openapi:test-entire-package"
}, {
"label": "Extension version : 0.3.18",
"label": "Extension version : 0.3.19",
"id": "tools.openapi.version",
"command": "generate:show-version-dialog"
}, {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "gs-gs.staruml-cefact",
"title": "OpenAPI3.0 Generator",
"description": "StarUML Extension for generating OpenAPI 3.0 Specs from the UML Diagrams. \nImplementation Rules are according to https://edi3.org/uml-profile/ \nExtension Source Code: https://github.com/gs-gs/staruml-cefact \nExtension version: 0.3.18",
"version": "0.3.18",
"description": "StarUML Extension for generating OpenAPI 3.0 Specs from the UML Diagrams. \nImplementation Rules are according to https://edi3.org/uml-profile/ \nExtension Source Code: https://github.com/gs-gs/staruml-cefact \nExtension version: 0.3.19",
"version": "0.3.19",
"engines": {
"staruml": ">=3.0.0"
},
Expand Down
46 changes: 24 additions & 22 deletions src/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,21 @@ class Paths {
}

/*
1. Generate query type paramters for 'GET' method if non-id parameters (Issue : #6)
2. write simple path object of POST operations
Pattern : (GET/POST) : '/{pathname}'
1. Write Simple path : Generate query type paramters for 'GET' method if non-id parameters (Issue : #6)
2. Write Simple path :
Pattern : (GET/POST) : '/{pathname}'
*/
this.writeSimplePathObject(pathsObject, mOperations, objInterfaceRealization);

/*
3. write {id} path object of (GET, PUT, DELETE) Operations
Pattern : (GET/PUT/DELETE/PATCH) : '/{pathname}/{id}'
3. Write {id} path object of (GET, PUT, DELETE) Operations
Pattern : (GET/PUT/DELETE/PATCH) : '/{pathname}/{id}'
*/
this.writeIDPathObject(mInterfaceView, objInterface, mOperations, mainPathsObject, objInterfaceRealization);

/*
4. Write path object for sub-resource pattern (Issue : #90)
Pattern : (GET/POST/DELETE/PUT) : '/{pathname}/{id}/{sub-resource-pathname}/{sub-resource-id}'
Pattern : (GET/POST/DELETE/PUT) : '/{pathname}/{id}/{sub-resource-pathname}/{sub-resource-id}'
*/
this.writeSubResourcePathObject(objInterface, objInterfaceRealization, mainPathsObject);

Expand Down Expand Up @@ -213,7 +213,7 @@ class Paths {
*/
writeIDPathObject(mInterfaceView, objInterface, mOperations, mainPathsObject, objInterfaceRealization) {
let checkOperationArr = mOperations.filter(item => {
return item.name == constant.GET || item.name == constant.PUT || item.name == constant.DELETE;
return item.name == constant.GET || item.name == constant.PUT || item.name == constant.DELETE || item.name == constant.PATCH;
});

if (checkOperationArr.length > 0) {
Expand Down Expand Up @@ -307,15 +307,15 @@ class Paths {

let end1Interface = interfaceAssociation.end1; //source example : imprtDeclarations
let end2Interface = interfaceAssociation.end2; //target : CargoLines
if(end2Interface.reference.name == 'travelDocuments'){
if (end2Interface.reference.name == 'travelDocuments') {
console.log("yes");
}
let uIR = app.repository.select("@UMLInterfaceRealization");
let resUIR = uIR.filter(irealization => {
return end2Interface.reference._id == irealization.target._id;
});
end2Interface.reference.operations.forEach(objOperation => {
/* interfaceRealization.target.operations.forEach(objOperation => { */
/* interfaceRealization.target.operations.forEach(objOperation => { */
/* Filter for visible operation Views from diagram elements (Interface) */


Expand Down Expand Up @@ -375,10 +375,10 @@ class Paths {
appJsonObj.schema = schemaObj;

refCName = '';
if(resUIR.length == 1){
if (resUIR.length == 1) {
let subResourceClass = resUIR[0].source;
refCName = subResourceClass.name
}else{
} else {
// This line is optional
refCName = interfaceRealization.source.name;
}
Expand Down Expand Up @@ -465,10 +465,10 @@ class Paths {
appJsonSingleObj.schema = schemaSingleObj;

refCName = '';
if(resUIR.length == 1){
if (resUIR.length == 1) {
let subResourceClass = resUIR[0].source;
refCName = subResourceClass.name
}else{
} else {
// This line is optional
refCName = interfaceRealization.source.name;
}
Expand All @@ -488,14 +488,9 @@ class Paths {
mainPathsObject[mICPath] = pathsObject;
}

if(mICPath == '/applicants/{id}/travelDocuments'){
console.log("#111 : ",mICPath);
}


if(resUIR.length == 1){
if (resUIR.length == 1) {
let subResourceClass = resUIR[0].source;
pathsObject.post = this.operations.postForSubResource(interfaceRealization, end1Interface,subResourceClass);
pathsObject.post = this.operations.postForSubResource(interfaceRealization, end1Interface, subResourceClass);
}


Expand Down Expand Up @@ -567,6 +562,13 @@ class Paths {
let description2 = (end2Interface.reference.attributes[0].documentation ? utils.buildDescription(end2Interface.reference.attributes[0].documentation) : constant.STR_MISSING_DESCRIPTION);
utils.buildParameter(name2, "path", description2, true, objSingleSchema, paramsSingleObject);

if (resUIR.length == 1) {
let subResourceClass = resUIR[0].source;
let requestBodyObj = {}
wOperationSingleObject.requestBody = requestBodyObj;
utils.buildRequestBodyForSubResource(subResourceClass, requestBodyObj);
}


/* -------- Add response body -------- */
let responsesSingleObj = {};
Expand All @@ -587,10 +589,10 @@ class Paths {
appJsonSingleObj.schema = schemaSingleObj;

refCName = '';
if(resUIR.length == 1){
if (resUIR.length == 1) {
let subResourceClass = resUIR[0].source;
refCName = subResourceClass.name
}else{
} else {
// This line is optional
refCName = interfaceRealization.source.name;
}
Expand Down