forked from loafle/openapi-generator-original
Use postman notation (#17028)
* use Postman notation for path parameter * Regenerate samples
This commit is contained in:
parent
279a92c2ed
commit
09060c6c22
@ -131,6 +131,7 @@ public class PostmanCollectionCodegen extends DefaultCodegen implements CodegenC
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
// create Postman variable from every path parameter
|
||||
if(pathParamsAsVariables && parameter.isPathParam) {
|
||||
variables.add(new PostmanVariable()
|
||||
.addName(parameter.paramName)
|
||||
@ -216,13 +217,16 @@ public class PostmanCollectionCodegen extends DefaultCodegen implements CodegenC
|
||||
|
||||
for(CodegenOperation codegenOperation : opList) {
|
||||
|
||||
// use Postman notation for path parameter
|
||||
codegenOperation.path = replacesBracesInPath(codegenOperation.path);
|
||||
|
||||
if(pathParamsAsVariables) {
|
||||
// create Postman variable from path parameter
|
||||
codegenOperation.path = doubleCurlyBraces(codegenOperation.path);
|
||||
} else {
|
||||
// use Postman notation for path parameter
|
||||
codegenOperation.path = replacesBracesInPath(codegenOperation.path);
|
||||
// set value of path parameter with corresponding env variable
|
||||
for(CodegenParameter codegenParameter : codegenOperation.pathParams) {
|
||||
codegenParameter.defaultValue = "{{" + codegenParameter.paramName + "}}";
|
||||
}
|
||||
}
|
||||
|
||||
codegenOperation.summary = getSummary(codegenOperation);
|
||||
|
||||
// request headers
|
||||
|
@ -39,7 +39,7 @@
|
||||
{{#pathParams}}
|
||||
{
|
||||
"key": "{{paramName}}",
|
||||
"value": "",
|
||||
"value": "{{defaultValue}}",
|
||||
"description": "{{description}}"
|
||||
}{{^-last}},{{/-last}}
|
||||
{{/pathParams}}
|
||||
|
@ -161,7 +161,9 @@ public class PostmanCollectionCodegenTest {
|
||||
"key\": \"groupId\", \"value\": \"1\", \"type\": \"number\"");
|
||||
|
||||
// verify request endpoint
|
||||
TestUtils.assertFileContains(path, "\"name\": \"/users/{{userId}}\"");
|
||||
TestUtils.assertFileContains(path, "\"name\": \"/users/:userId\"");
|
||||
// verify path parameter value
|
||||
TestUtils.assertFileContains(path, "key\": \"userId\", \"value\": \"{{userId}}\",");
|
||||
|
||||
}
|
||||
|
||||
@ -196,7 +198,9 @@ public class PostmanCollectionCodegenTest {
|
||||
assertFileContains(path, "{{MY_VAR_NAME}}");
|
||||
|
||||
// verify request endpoint
|
||||
TestUtils.assertFileContains(path, "\"name\": \"/users/{{userId}}\"");
|
||||
TestUtils.assertFileContains(path, "\"name\": \"/users/:userId\"");
|
||||
// verify path parameter value
|
||||
TestUtils.assertFileContains(path, "key\": \"userId\", \"value\": \"{{userId}}\",");
|
||||
|
||||
}
|
||||
|
||||
@ -303,7 +307,10 @@ public class PostmanCollectionCodegenTest {
|
||||
Path path = Paths.get(output + "/postman.json");
|
||||
assertFileExists(path);
|
||||
// verify request name (from path)
|
||||
assertFileContains(path, "\"name\": \"/users/{{userId}}\"");
|
||||
assertFileContains(path, "\"name\": \"/users/:userId\"");
|
||||
// verify path parameter value
|
||||
TestUtils.assertFileContains(path, "key\": \"userId\", \"value\": \"{{userId}}\",");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -116,7 +116,7 @@
|
||||
"variable": [
|
||||
{
|
||||
"key": "groupId",
|
||||
"value": "",
|
||||
"value": "1",
|
||||
"description": "group Id"
|
||||
}
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user