@@ -78,4 +78,36 @@ public void verifyOperatorName() throws IOException {
7878 assertFileNotContains (path , "val X3D = Value(\" !=\" )" );
7979 }
8080
81+ @ Test
82+ public void verifyApiKeyLocations () throws IOException {
83+ File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
84+ output .deleteOnExit ();
85+ String outputPath = output .getAbsolutePath ().replace ('\\' , '/' );
86+
87+ OpenAPI openAPI = new OpenAPIParser ()
88+ .readLocation ("src/test/resources/bugs/issue_13474.json" , null , new ParseOptions ()).getOpenAPI ();
89+
90+ ScalaSttpClientCodegen codegen = new ScalaSttpClientCodegen ();
91+ codegen .setOutputDir (output .getAbsolutePath ());
92+ codegen .additionalProperties ().put (CXFServerFeatures .LOAD_TEST_DATA_FROM_FILE , "true" );
93+
94+ ClientOptInput input = new ClientOptInput ();
95+ input .openAPI (openAPI );
96+ input .config (codegen );
97+
98+ DefaultGenerator generator = new DefaultGenerator ();
99+
100+ generator .setGeneratorPropertyDefault (CodegenConstants .MODELS , "true" );
101+ generator .setGeneratorPropertyDefault (CodegenConstants .MODEL_TESTS , "false" );
102+ generator .setGeneratorPropertyDefault (CodegenConstants .MODEL_DOCS , "false" );
103+ generator .setGeneratorPropertyDefault (CodegenConstants .APIS , "true" );
104+ generator .setGeneratorPropertyDefault (CodegenConstants .SUPPORTING_FILES , "false" );
105+ generator .opts (input ).generate ();
106+
107+ Path path = Paths .get (outputPath + "/src/main/scala/org/openapitools/client/api/DefaultApi.scala" );
108+ assertFileContains (path , ".method(Method.GET, uri\" $baseUrl/entities/?api_key=${apiKeyQuery}\" )\n " );
109+ assertFileContains (path , ".header(\" X-Api-Key\" , apiKeyHeader)" );
110+ assertFileContains (path , ".cookie(\" apikey\" , apiKeyCookie)" );
111+ }
112+
81113}
0 commit comments