Skip to content

Commit

Permalink
Merge pull request #67 from gcatanese/add-query-parameter-description
Browse files Browse the repository at this point in the history
Add query param description
  • Loading branch information
gcatanese authored Dec 1, 2023
2 parents 9b20ffe + 7efcba4 commit de697b0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/resources/postman-v2/item.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
{
"key": "{{paramName}}",
"value": "{{example}}",
"description": "{{{description}}}",
"disabled": {{#required}}false{{/required}}{{^required}}true{{/required}}
}{{^-last}},{{/-last}}
{{/queryParams}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ public void testMgmtApi() throws IOException, ParseException {
}

@Test
public void testRequiredQueryParameter() throws IOException, ParseException {
public void testRequiredQueryParameter() throws IOException {

File output = Files.createTempDirectory("postmantest_").toFile();
output.deleteOnExit();
Expand All @@ -641,9 +641,32 @@ public void testRequiredQueryParameter() throws IOException, ParseException {
Path path = Paths.get(output + "/postman.json");
TestUtils.assertFileExists(path);
// verify param pUserId is set as disabled=false
TestUtils.assertFileContains(path, "{ \"key\": \"pUserId\", \"value\": \"888\", \"disabled\": false");
TestUtils.assertFileContains(path, "{ \"key\": \"pUserId\", \"value\": \"888\", \"description\": \"Query Id.\", \"disabled\": false");

}

@Test
public void testQueryParameterDescription() throws IOException {

File output = Files.createTempDirectory("postmantest_").toFile();
output.deleteOnExit();

final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("postman-v2")
.setInputSpec("./src/test/resources/SampleProject.yaml")
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));

DefaultGenerator generator = new DefaultGenerator();
List<File> files = generator.opts(configurator.toClientOptInput()).generate();

System.out.println(files);
files.forEach(File::deleteOnExit);

Path path = Paths.get(output + "/postman.json");
TestUtils.assertFileExists(path);
// verify param pUserId is set as disabled=false
TestUtils.assertFileContains(path, "{ \"key\": \"pUserId\", \"value\": \"888\", \"description\": \"Query Id.\"");

}

}

0 comments on commit de697b0

Please sign in to comment.