Skip to content

Commit

Permalink
Change default value of 'pathParamsAsVariables' config option (#16404)
Browse files Browse the repository at this point in the history
* Change default value for config option

* Regenerate samples
  • Loading branch information
gcatanese committed Sep 20, 2023
1 parent 9b39887 commit 254b359
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
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

0 comments on commit 254b359

Please sign in to comment.