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

Change default value of 'pathParamsAsVariables' config option #16404

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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class PostmanCollectionCodegen extends DefaultCodegen implements CodegenC
public static final String FOLDER_STRATEGY_DEFAULT_VALUE = "Tags";
// Select whether to create Postman variables for path templates
public static final String PATH_PARAMS_AS_VARIABLES = "pathParamsAsVariables";
public static final Boolean PATH_PARAMS_AS_VARIABLES_DEFAULT_VALUE = true;
public static final Boolean PATH_PARAMS_AS_VARIABLES_DEFAULT_VALUE = false;

public static final String POSTMAN_FILE_DEFAULT_VALUE = "postman.json";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public void testVariables() throws Exception {
final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("postman-collection")
.setInputSpec("src/test/resources/3_0/postman-collection/SampleProject.yaml")
.addAdditionalProperty(PostmanCollectionCodegen.PATH_PARAMS_AS_VARIABLES, true)
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));

final ClientOptInput clientOptInput = configurator.toClientOptInput();
Expand Down Expand Up @@ -165,6 +166,7 @@ public void testVariablesInRequestExample() throws Exception {
final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("postman-collection")
.setInputSpec("src/test/resources/3_0/postman-collection/BasicVariablesInExample.yaml")
.addAdditionalProperty(PostmanCollectionCodegen.PATH_PARAMS_AS_VARIABLES, true)
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));

final ClientOptInput clientOptInput = configurator.toClientOptInput();
Expand Down Expand Up @@ -197,6 +199,7 @@ public void testSkipPostmanVariables() throws Exception {
.setGeneratorName("postman-collection")
.addAdditionalProperty(PostmanCollectionCodegen.POSTMAN_VARIABLES, false)
.setInputSpec("src/test/resources/3_0/postman-collection/BasicVariablesInExample.yaml")
.addAdditionalProperty(PostmanCollectionCodegen.PATH_PARAMS_AS_VARIABLES, true)
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));

final ClientOptInput clientOptInput = configurator.toClientOptInput();
Expand Down Expand Up @@ -224,7 +227,6 @@ public void testGenerateWithoutPathParamsVariables() throws Exception {

final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("postman-collection")
.addAdditionalProperty(PostmanCollectionCodegen.PATH_PARAMS_AS_VARIABLES, false)
.setInputSpec("src/test/resources/3_0/postman-collection/SampleProject.yaml")
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));

Expand Down Expand Up @@ -277,6 +279,7 @@ public void testNamingRequestsWithUrl() throws Exception {
final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("postman-collection")
.setInputSpec("src/test/resources/3_0/postman-collection/SampleProject.yaml")
.addAdditionalProperty(PostmanCollectionCodegen.PATH_PARAMS_AS_VARIABLES, true)
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));

final ClientOptInput clientOptInput = configurator.toClientOptInput();
Expand Down
28 changes: 9 additions & 19 deletions samples/schema/postman-collection/postman.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "default",
"item": [
{
"name": "/users/{{userId}} (DEPRECATED)",
"name": "/users/{userId} (DEPRECATED)",
"description": "Update the information of an existing user.",
"item": [
{
Expand Down Expand Up @@ -52,13 +52,13 @@
}
},
"url": {
"raw": "{{baseUrl}}/users/{{userId}}",
"raw": "{{baseUrl}}/users/{userId}",
"host": [
"{{baseUrl}}"
],
"path": [
"users",
"{{userId}}"
"{userId}"
],
"variable": [
{
Expand All @@ -81,7 +81,7 @@
"name": "advanced",
"item": [
{
"name": "/groups/{{groupId}}",
"name": "/groups/{groupId}",
"description": "Get group of users",
"item": [
{
Expand All @@ -105,13 +105,13 @@
}
},
"url": {
"raw": "{{baseUrl}}/groups/{{groupId}}",
"raw": "{{baseUrl}}/groups/{groupId}",
"host": [
"{{baseUrl}}"
],
"path": [
"groups",
"{{groupId}}"
"{groupId}"
],
"variable": [
{
Expand All @@ -129,7 +129,7 @@
]
},
{
"name": "/users/{{userId}}",
"name": "/users/{userId}",
"description": "Retrieve the information of the user with the matching user ID.",
"item": [
{
Expand Down Expand Up @@ -163,13 +163,13 @@
}
},
"url": {
"raw": "{{baseUrl}}/users/{{userId}}",
"raw": "{{baseUrl}}/users/{userId}",
"host": [
"{{baseUrl}}"
],
"path": [
"users",
"{{userId}}"
"{userId}"
],
"variable": [
{
Expand Down Expand Up @@ -328,20 +328,10 @@
"value": "v1",
"type": "string"
},
{
"key": "groupId",
"value": "1",
"type": "number"
},
{
"key": "port",
"value": "5000",
"type": "string"
},
{
"key": "userId",
"value": "",
"type": "number"
}
]
}
Expand Down
Loading