mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 22:20:56 +00:00
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
|
@Override
|
||||||
public void postProcessParameter(CodegenParameter parameter) {
|
public void postProcessParameter(CodegenParameter parameter) {
|
||||||
|
// create Postman variable from every path parameter
|
||||||
if(pathParamsAsVariables && parameter.isPathParam) {
|
if(pathParamsAsVariables && parameter.isPathParam) {
|
||||||
variables.add(new PostmanVariable()
|
variables.add(new PostmanVariable()
|
||||||
.addName(parameter.paramName)
|
.addName(parameter.paramName)
|
||||||
@ -216,13 +217,16 @@ public class PostmanCollectionCodegen extends DefaultCodegen implements CodegenC
|
|||||||
|
|
||||||
for(CodegenOperation codegenOperation : opList) {
|
for(CodegenOperation codegenOperation : opList) {
|
||||||
|
|
||||||
|
// use Postman notation for path parameter
|
||||||
|
codegenOperation.path = replacesBracesInPath(codegenOperation.path);
|
||||||
|
|
||||||
if(pathParamsAsVariables) {
|
if(pathParamsAsVariables) {
|
||||||
// create Postman variable from path parameter
|
// set value of path parameter with corresponding env variable
|
||||||
codegenOperation.path = doubleCurlyBraces(codegenOperation.path);
|
for(CodegenParameter codegenParameter : codegenOperation.pathParams) {
|
||||||
} else {
|
codegenParameter.defaultValue = "{{" + codegenParameter.paramName + "}}";
|
||||||
// use Postman notation for path parameter
|
}
|
||||||
codegenOperation.path = replacesBracesInPath(codegenOperation.path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
codegenOperation.summary = getSummary(codegenOperation);
|
codegenOperation.summary = getSummary(codegenOperation);
|
||||||
|
|
||||||
// request headers
|
// request headers
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
{{#pathParams}}
|
{{#pathParams}}
|
||||||
{
|
{
|
||||||
"key": "{{paramName}}",
|
"key": "{{paramName}}",
|
||||||
"value": "",
|
"value": "{{defaultValue}}",
|
||||||
"description": "{{description}}"
|
"description": "{{description}}"
|
||||||
}{{^-last}},{{/-last}}
|
}{{^-last}},{{/-last}}
|
||||||
{{/pathParams}}
|
{{/pathParams}}
|
||||||
|
@ -161,7 +161,9 @@ public class PostmanCollectionCodegenTest {
|
|||||||
"key\": \"groupId\", \"value\": \"1\", \"type\": \"number\"");
|
"key\": \"groupId\", \"value\": \"1\", \"type\": \"number\"");
|
||||||
|
|
||||||
// verify request endpoint
|
// 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}}");
|
assertFileContains(path, "{{MY_VAR_NAME}}");
|
||||||
|
|
||||||
// verify request endpoint
|
// 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");
|
Path path = Paths.get(output + "/postman.json");
|
||||||
assertFileExists(path);
|
assertFileExists(path);
|
||||||
// verify request name (from 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
|
@Test
|
||||||
|
@ -116,7 +116,7 @@
|
|||||||
"variable": [
|
"variable": [
|
||||||
{
|
{
|
||||||
"key": "groupId",
|
"key": "groupId",
|
||||||
"value": "",
|
"value": "1",
|
||||||
"description": "group Id"
|
"description": "group Id"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user