diff --git a/modules/openapi-generator/src/main/resources/postman-collection/item.mustache b/modules/openapi-generator/src/main/resources/postman-collection/item.mustache index a9cc9c49da7..806e62688be 100644 --- a/modules/openapi-generator/src/main/resources/postman-collection/item.mustache +++ b/modules/openapi-generator/src/main/resources/postman-collection/item.mustache @@ -48,7 +48,8 @@ {{#queryParams}} { "key": "{{paramName}}", - "value": "{{example}}" + "value": "{{example}}", + "disabled": {{#required}}false{{/required}}{{^required}}true{{/required}} }{{^-last}},{{/-last}} {{/queryParams}} ] diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/postman/PostmanCollectionCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/postman/PostmanCollectionCodegenTest.java index 4463a2c5c08..0ee6f5a8f35 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/postman/PostmanCollectionCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/postman/PostmanCollectionCodegenTest.java @@ -755,4 +755,28 @@ public class PostmanCollectionCodegenTest { assertEquals(true, postmanV2Generator.codegenOperationsByTag.containsKey("default")); } + @Test + public void testRequiredQueryParameter() throws IOException { + + File output = Files.createTempDirectory("postmantest_").toFile(); + output.deleteOnExit(); + + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("postman-collection") + .setInputSpec("src/test/resources/3_0/postman-collection/SampleProject.yaml") + .setOutputDir(output.getAbsolutePath().replace("\\", "/")); + + DefaultGenerator generator = new DefaultGenerator(); + List 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\", \"disabled\": false"); + + } + } diff --git a/samples/schema/postman-collection/postman.json b/samples/schema/postman-collection/postman.json index 8a39ae60676..cd19d5735d1 100644 --- a/samples/schema/postman-collection/postman.json +++ b/samples/schema/postman-collection/postman.json @@ -285,7 +285,8 @@ "query": [ { "key": "pUserId", - "value": "888" + "value": "888", + "disabled": false } ] },