mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-10-14 00:13:50 +00:00
Generators "scala-sttp" and "scala-sttp4" produce valid code when using APIKeyQuery, APIKeyHeader and APIKeyCookie #13474 (#21551)
* fix: using APIKeyQuery and APIKeyHeader generates invalid code (#13474) * fix: include test * fix: also fix auth generation for sttp4 * fix: maintain prev whitespaces & update generated APIs
This commit is contained in:
parent
8862b960f8
commit
7f2ee8520e
@ -22,13 +22,13 @@ class {{classname}}(baseUrl: String) {
|
|||||||
{{/javadocRenderer}}
|
{{/javadocRenderer}}
|
||||||
def {{operationId}}({{>methodParameters}}): Request[{{#separateErrorChannel}}Either[ResponseException[String, Exception], {{>operationReturnType}}]{{/separateErrorChannel}}{{^separateErrorChannel}}{{>operationReturnType}}{{/separateErrorChannel}}, Any] =
|
def {{operationId}}({{>methodParameters}}): Request[{{#separateErrorChannel}}Either[ResponseException[String, Exception], {{>operationReturnType}}]{{/separateErrorChannel}}{{^separateErrorChannel}}{{>operationReturnType}}{{/separateErrorChannel}}, Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.{{httpMethod.toUpperCase}}, uri"$baseUrl{{{path}}}{{#queryParams.0}}?{{#queryParams}}{{baseName}}=${ {{{paramName}}} }{{^-last}}&{{/-last}}{{/queryParams}}{{/queryParams.0}}{{#isApiKey}}{{#isKeyInQuery}}{{^queryParams.0}}?{{/queryParams.0}}{{#queryParams.0}}&{{/queryParams.0}}{{keyParamName}}=${apiKey.value}&{{/isKeyInQuery}}{{/isApiKey}}")
|
.method(Method.{{httpMethod.toUpperCase}}, uri"$baseUrl{{{path}}}{{#queryParams.0}}?{{/queryParams.0}}{{#queryParams}}{{baseName}}=${ {{paramName}} }{{^-last}}&{{/-last}}{{/queryParams}}{{#authMethods}}{{#isApiKey}}{{#isKeyInQuery}}{{#queryParams.0}}&{{/queryParams.0}}{{^queryParams.0}}?{{/queryParams.0}}{{keyParamName}}=${apiKeyQuery}{{/isKeyInQuery}}{{/isApiKey}}{{/authMethods}}")
|
||||||
.contentType({{#consumes.0}}"{{{mediaType}}}"{{/consumes.0}}{{^consumes}}"application/json"{{/consumes}}){{#headerParams}}
|
.contentType({{#consumes.0}}"{{{mediaType}}}"{{/consumes.0}}{{^consumes}}"application/json"{{/consumes}}){{#headerParams}}
|
||||||
.header({{>paramCreation}}){{/headerParams}}{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
|
.header({{>paramCreation}}){{/headerParams}}{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
|
||||||
.auth.basic(username, password){{/isBasicBasic}}{{#isBasicBearer}}
|
.auth.basic(username, password){{/isBasicBasic}}{{#isBasicBearer}}
|
||||||
.auth.bearer(bearerToken){{/isBasicBearer}}{{/isBasic}}{{#isApiKey}}{{#isKeyInHeader}}
|
.auth.bearer(bearerToken){{/isBasicBearer}}{{/isBasic}}{{#isApiKey}}{{#isKeyInHeader}}
|
||||||
.header("{{keyParamName}}", apiKey){{/isKeyInHeader}}{{#isKeyInCookie}}
|
.header("{{keyParamName}}", apiKeyHeader){{/isKeyInHeader}}{{#isKeyInCookie}}
|
||||||
.cookie("{{keyParamName}}", apiKey){{/isKeyInCookie}}{{/isApiKey}}{{/authMethods}}{{#formParams.0}}{{^isMultipart}}
|
.cookie("{{keyParamName}}", apiKeyCookie){{/isKeyInCookie}}{{/isApiKey}}{{/authMethods}}{{#formParams.0}}{{^isMultipart}}
|
||||||
.body(Map({{#formParams}}
|
.body(Map({{#formParams}}
|
||||||
{{>paramFormCreation}}{{^-last}},{{/-last}}{{/formParams}}
|
{{>paramFormCreation}}{{^-last}},{{/-last}}{{/formParams}}
|
||||||
)){{/isMultipart}}{{#isMultipart}}
|
)){{/isMultipart}}{{#isMultipart}}
|
||||||
|
@ -1 +1 @@
|
|||||||
{{#authMethods.0}}{{#authMethods}}{{#isApiKey}}apiKey: String{{/isApiKey}}{{#isBasic}}{{#isBasicBasic}}username: String, password: String{{/isBasicBasic}}{{#isBasicBearer}}bearerToken: String{{/isBasicBearer}}{{/isBasic}}{{^-last}}, {{/-last}}{{/authMethods}})({{/authMethods.0}}{{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{/required}}{{^required}}{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}Option[{{dataType}}]{{/isContainer}}{{/required}}{{^defaultValue}}{{^required}}{{^isContainer}} = None{{/isContainer}}{{/required}}{{/defaultValue}}{{^-last}}, {{/-last}}{{/allParams}}
|
{{#authMethods.0}}{{#authMethods}}{{#isApiKey}}{{#isKeyInHeader}}apiKeyHeader: String{{/isKeyInHeader}}{{#isKeyInQuery}}apiKeyQuery: String{{/isKeyInQuery}}{{#isKeyInCookie}}apiKeyCookie: String{{/isKeyInCookie}}{{/isApiKey}}{{#isBasic}}{{#isBasicBasic}}username: String, password: String{{/isBasicBasic}}{{#isBasicBearer}}bearerToken: String{{/isBasicBearer}}{{/isBasic}}{{^-last}}, {{/-last}}{{/authMethods}})({{/authMethods.0}}{{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{/required}}{{^required}}{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}Option[{{dataType}}]{{/isContainer}}{{/required}}{{^defaultValue}}{{^required}}{{^isContainer}} = None{{/isContainer}}{{/required}}{{/defaultValue}}{{^-last}}, {{/-last}}{{/allParams}}
|
||||||
|
@ -22,13 +22,13 @@ class {{classname}}(baseUrl: String) {
|
|||||||
{{/javadocRenderer}}
|
{{/javadocRenderer}}
|
||||||
def {{operationId}}({{>methodParameters}}): Request[{{#separateErrorChannel}}Either[ResponseException[String, Exception], {{>operationReturnType}}]{{/separateErrorChannel}}{{^separateErrorChannel}}{{>operationReturnType}}{{/separateErrorChannel}}] =
|
def {{operationId}}({{>methodParameters}}): Request[{{#separateErrorChannel}}Either[ResponseException[String, Exception], {{>operationReturnType}}]{{/separateErrorChannel}}{{^separateErrorChannel}}{{>operationReturnType}}{{/separateErrorChannel}}] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.{{httpMethod.toUpperCase}}, uri"$baseUrl{{{path}}}{{#queryParams.0}}?{{#queryParams}}{{baseName}}=${ {{{paramName}}} }{{^-last}}&{{/-last}}{{/queryParams}}{{/queryParams.0}}{{#isApiKey}}{{#isKeyInQuery}}{{^queryParams.0}}?{{/queryParams.0}}{{#queryParams.0}}&{{/queryParams.0}}{{keyParamName}}=${apiKey.value}&{{/isKeyInQuery}}{{/isApiKey}}")
|
.method(Method.{{httpMethod.toUpperCase}}, uri"$baseUrl{{{path}}}{{#queryParams.0}}?{{/queryParams.0}}{{#queryParams}}{{baseName}}=${ {{paramName}} }{{^-last}}&{{/-last}}{{/queryParams}}{{#authMethods}}{{#isApiKey}}{{#isKeyInQuery}}{{#queryParams.0}}&{{/queryParams.0}}{{^queryParams.0}}?{{/queryParams.0}}{{keyParamName}}=${apiKeyQuery}{{/isKeyInQuery}}{{/isApiKey}}{{/authMethods}}")
|
||||||
.contentType({{#consumes.0}}"{{{mediaType}}}"{{/consumes.0}}{{^consumes}}"application/json"{{/consumes}}){{#headerParams}}
|
.contentType({{#consumes.0}}"{{{mediaType}}}"{{/consumes.0}}{{^consumes}}"application/json"{{/consumes}}){{#headerParams}}
|
||||||
.header({{>paramCreation}}){{/headerParams}}{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
|
.header({{>paramCreation}}){{/headerParams}}{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
|
||||||
.auth.basic(username, password){{/isBasicBasic}}{{#isBasicBearer}}
|
.auth.basic(username, password){{/isBasicBasic}}{{#isBasicBearer}}
|
||||||
.auth.bearer(bearerToken){{/isBasicBearer}}{{/isBasic}}{{#isApiKey}}{{#isKeyInHeader}}
|
.auth.bearer(bearerToken){{/isBasicBearer}}{{/isBasic}}{{#isApiKey}}{{#isKeyInHeader}}
|
||||||
.header("{{keyParamName}}", apiKey){{/isKeyInHeader}}{{#isKeyInCookie}}
|
.header("{{keyParamName}}", apiKeyHeader){{/isKeyInHeader}}{{#isKeyInCookie}}
|
||||||
.cookie("{{keyParamName}}", apiKey){{/isKeyInCookie}}{{/isApiKey}}{{/authMethods}}{{#formParams.0}}{{^isMultipart}}
|
.cookie("{{keyParamName}}", apiKeyCookie){{/isKeyInCookie}}{{/isApiKey}}{{/authMethods}}{{#formParams.0}}{{^isMultipart}}
|
||||||
.body(Map({{#formParams}}
|
.body(Map({{#formParams}}
|
||||||
{{>paramFormCreation}}{{^-last}},{{/-last}}{{/formParams}}
|
{{>paramFormCreation}}{{^-last}},{{/-last}}{{/formParams}}
|
||||||
)){{/isMultipart}}{{#isMultipart}}
|
)){{/isMultipart}}{{#isMultipart}}
|
||||||
|
@ -1 +1 @@
|
|||||||
{{#authMethods.0}}{{#authMethods}}{{#isApiKey}}apiKey: String{{/isApiKey}}{{#isBasic}}{{#isBasicBasic}}username: String, password: String{{/isBasicBasic}}{{#isBasicBearer}}bearerToken: String{{/isBasicBearer}}{{/isBasic}}{{^-last}}, {{/-last}}{{/authMethods}})({{/authMethods.0}}{{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{/required}}{{^required}}{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}Option[{{dataType}}]{{/isContainer}}{{/required}}{{^defaultValue}}{{^required}}{{^isContainer}} = None{{/isContainer}}{{/required}}{{/defaultValue}}{{^-last}}, {{/-last}}{{/allParams}}
|
{{#authMethods.0}}{{#authMethods}}{{#isApiKey}}{{#isKeyInHeader}}apiKeyHeader: String{{/isKeyInHeader}}{{#isKeyInQuery}}apiKeyQuery: String{{/isKeyInQuery}}{{#isKeyInCookie}}apiKeyCookie: String{{/isKeyInCookie}}{{/isApiKey}}{{#isBasic}}{{#isBasicBasic}}username: String, password: String{{/isBasicBasic}}{{#isBasicBearer}}bearerToken: String{{/isBasicBearer}}{{/isBasic}}{{^-last}}, {{/-last}}{{/authMethods}})({{/authMethods.0}}{{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{/required}}{{^required}}{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}Option[{{dataType}}]{{/isContainer}}{{/required}}{{^defaultValue}}{{^required}}{{^isContainer}} = None{{/isContainer}}{{/required}}{{/defaultValue}}{{^-last}}, {{/-last}}{{/allParams}}
|
@ -0,0 +1,56 @@
|
|||||||
|
package org.openapitools.codegen.scala;
|
||||||
|
|
||||||
|
import io.swagger.parser.OpenAPIParser;
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
|
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||||
|
import org.openapitools.codegen.ClientOptInput;
|
||||||
|
import org.openapitools.codegen.CodegenConstants;
|
||||||
|
import org.openapitools.codegen.DefaultGenerator;
|
||||||
|
import org.openapitools.codegen.languages.ScalaSttp4ClientCodegen;
|
||||||
|
import org.openapitools.codegen.languages.features.CXFServerFeatures;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
import static org.openapitools.codegen.TestUtils.assertFileContains;
|
||||||
|
|
||||||
|
public class Sttp4CodegenTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void verifyApiKeyLocations() throws IOException {
|
||||||
|
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||||
|
output.deleteOnExit();
|
||||||
|
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||||
|
|
||||||
|
OpenAPI openAPI = new OpenAPIParser()
|
||||||
|
.readLocation("src/test/resources/bugs/issue_13474.json", null, new ParseOptions()).getOpenAPI();
|
||||||
|
|
||||||
|
ScalaSttp4ClientCodegen codegen = new ScalaSttp4ClientCodegen();
|
||||||
|
codegen.setOutputDir(output.getAbsolutePath());
|
||||||
|
codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true");
|
||||||
|
|
||||||
|
ClientOptInput input = new ClientOptInput();
|
||||||
|
input.openAPI(openAPI);
|
||||||
|
input.config(codegen);
|
||||||
|
|
||||||
|
DefaultGenerator generator = new DefaultGenerator();
|
||||||
|
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
|
||||||
|
generator.opts(input).generate();
|
||||||
|
|
||||||
|
Path path = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/api/DefaultApi.scala");
|
||||||
|
assertFileContains(path, ".method(Method.GET, uri\"$baseUrl/entities/?api_key=${apiKeyQuery}\")\n");
|
||||||
|
assertFileContains(path, ".header(\"X-Api-Key\", apiKeyHeader)");
|
||||||
|
assertFileContains(path, ".cookie(\"apikey\", apiKeyCookie)");
|
||||||
|
}
|
||||||
|
}
|
@ -78,4 +78,36 @@ public class SttpCodegenTest {
|
|||||||
assertFileNotContains(path, "val X3D = Value(\"!=\")");
|
assertFileNotContains(path, "val X3D = Value(\"!=\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void verifyApiKeyLocations() throws IOException {
|
||||||
|
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||||
|
output.deleteOnExit();
|
||||||
|
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||||
|
|
||||||
|
OpenAPI openAPI = new OpenAPIParser()
|
||||||
|
.readLocation("src/test/resources/bugs/issue_13474.json", null, new ParseOptions()).getOpenAPI();
|
||||||
|
|
||||||
|
ScalaSttpClientCodegen codegen = new ScalaSttpClientCodegen();
|
||||||
|
codegen.setOutputDir(output.getAbsolutePath());
|
||||||
|
codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true");
|
||||||
|
|
||||||
|
ClientOptInput input = new ClientOptInput();
|
||||||
|
input.openAPI(openAPI);
|
||||||
|
input.config(codegen);
|
||||||
|
|
||||||
|
DefaultGenerator generator = new DefaultGenerator();
|
||||||
|
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
|
||||||
|
generator.opts(input).generate();
|
||||||
|
|
||||||
|
Path path = Paths.get(outputPath + "/src/main/scala/org/openapitools/client/api/DefaultApi.scala");
|
||||||
|
assertFileContains(path, ".method(Method.GET, uri\"$baseUrl/entities/?api_key=${apiKeyQuery}\")\n");
|
||||||
|
assertFileContains(path, ".header(\"X-Api-Key\", apiKeyHeader)");
|
||||||
|
assertFileContains(path, ".cookie(\"apikey\", apiKeyCookie)");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
{
|
||||||
|
"openapi": "3.0.2",
|
||||||
|
"info": {
|
||||||
|
"title": "Sample ApPI",
|
||||||
|
"version": "0.1.0"
|
||||||
|
},
|
||||||
|
"paths": {
|
||||||
|
"/entities/": {
|
||||||
|
"get": {
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Successful Response",
|
||||||
|
"content": {
|
||||||
|
"text/plain" : {
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"APIKeyHeader": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"APIKeyQuery": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"APIKeyCookie": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"components": {
|
||||||
|
"securitySchemes": {
|
||||||
|
"APIKeyHeader": {
|
||||||
|
"type": "apiKey",
|
||||||
|
"in": "header",
|
||||||
|
"name": "X-Api-Key"
|
||||||
|
},
|
||||||
|
"APIKeyQuery": {
|
||||||
|
"type": "apiKey",
|
||||||
|
"in": "query",
|
||||||
|
"name": "api_key"
|
||||||
|
},
|
||||||
|
"APIKeyCookie": {
|
||||||
|
"type": "apiKey",
|
||||||
|
"in": "cookie",
|
||||||
|
"name": "apikey"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -103,12 +103,12 @@ class PetApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param petId ID of pet to return
|
* @param petId ID of pet to return
|
||||||
*/
|
*/
|
||||||
def getPetById(apiKey: String)(petId: Long
|
def getPetById(apiKeyHeader: String)(petId: Long
|
||||||
): Request[Either[ResponseException[String, Exception], Pet], Any] =
|
): Request[Either[ResponseException[String, Exception], Pet], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.GET, uri"$baseUrl/pet/${petId}")
|
.method(Method.GET, uri"$baseUrl/pet/${petId}")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.response(asJson[Pet])
|
.response(asJson[Pet])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,12 +47,12 @@ class StoreApi(baseUrl: String) {
|
|||||||
* Available security schemes:
|
* Available security schemes:
|
||||||
* api_key (apiKey)
|
* api_key (apiKey)
|
||||||
*/
|
*/
|
||||||
def getInventory(apiKey: String)(
|
def getInventory(apiKeyHeader: String)(
|
||||||
): Request[Either[ResponseException[String, Exception], Map[String, Int]], Any] =
|
): Request[Either[ResponseException[String, Exception], Map[String, Int]], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.GET, uri"$baseUrl/store/inventory")
|
.method(Method.GET, uri"$baseUrl/store/inventory")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.response(asJson[Map[String, Int]])
|
.response(asJson[Map[String, Int]])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,12 +34,12 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param user Created user object
|
* @param user Created user object
|
||||||
*/
|
*/
|
||||||
def createUser(apiKey: String)(user: User
|
def createUser(apiKeyHeader: String)(user: User
|
||||||
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.POST, uri"$baseUrl/user")
|
.method(Method.POST, uri"$baseUrl/user")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
@ -54,12 +54,12 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
def createUsersWithArrayInput(apiKey: String)(user: Seq[User]
|
def createUsersWithArrayInput(apiKeyHeader: String)(user: Seq[User]
|
||||||
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.POST, uri"$baseUrl/user/createWithArray")
|
.method(Method.POST, uri"$baseUrl/user/createWithArray")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
@ -74,12 +74,12 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
def createUsersWithListInput(apiKey: String)(user: Seq[User]
|
def createUsersWithListInput(apiKeyHeader: String)(user: Seq[User]
|
||||||
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.POST, uri"$baseUrl/user/createWithList")
|
.method(Method.POST, uri"$baseUrl/user/createWithList")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
@ -95,12 +95,12 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param username The name that needs to be deleted
|
* @param username The name that needs to be deleted
|
||||||
*/
|
*/
|
||||||
def deleteUser(apiKey: String)(username: String
|
def deleteUser(apiKeyHeader: String)(username: String
|
||||||
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.DELETE, uri"$baseUrl/user/${username}")
|
.method(Method.DELETE, uri"$baseUrl/user/${username}")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,12 +150,12 @@ class UserApi(baseUrl: String) {
|
|||||||
* Available security schemes:
|
* Available security schemes:
|
||||||
* api_key (apiKey)
|
* api_key (apiKey)
|
||||||
*/
|
*/
|
||||||
def logoutUser(apiKey: String)(
|
def logoutUser(apiKeyHeader: String)(
|
||||||
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.GET, uri"$baseUrl/user/logout")
|
.method(Method.GET, uri"$baseUrl/user/logout")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,12 +171,12 @@ class UserApi(baseUrl: String) {
|
|||||||
* @param username name that need to be deleted
|
* @param username name that need to be deleted
|
||||||
* @param user Updated user object
|
* @param user Updated user object
|
||||||
*/
|
*/
|
||||||
def updateUser(apiKey: String)(username: String, user: User
|
def updateUser(apiKeyHeader: String)(username: String, user: User
|
||||||
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.PUT, uri"$baseUrl/user/${username}")
|
.method(Method.PUT, uri"$baseUrl/user/${username}")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
|
@ -103,12 +103,12 @@ class PetApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param petId ID of pet to return
|
* @param petId ID of pet to return
|
||||||
*/
|
*/
|
||||||
def getPetById(apiKey: String)(petId: Long
|
def getPetById(apiKeyHeader: String)(petId: Long
|
||||||
): Request[Either[ResponseException[String, Exception], Pet], Any] =
|
): Request[Either[ResponseException[String, Exception], Pet], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.GET, uri"$baseUrl/pet/${petId}")
|
.method(Method.GET, uri"$baseUrl/pet/${petId}")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.response(asJson[Pet])
|
.response(asJson[Pet])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,12 +47,12 @@ class StoreApi(baseUrl: String) {
|
|||||||
* Available security schemes:
|
* Available security schemes:
|
||||||
* api_key (apiKey)
|
* api_key (apiKey)
|
||||||
*/
|
*/
|
||||||
def getInventory(apiKey: String)(
|
def getInventory(apiKeyHeader: String)(
|
||||||
): Request[Either[ResponseException[String, Exception], Map[String, Int]], Any] =
|
): Request[Either[ResponseException[String, Exception], Map[String, Int]], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.GET, uri"$baseUrl/store/inventory")
|
.method(Method.GET, uri"$baseUrl/store/inventory")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.response(asJson[Map[String, Int]])
|
.response(asJson[Map[String, Int]])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,12 +34,12 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param user Created user object
|
* @param user Created user object
|
||||||
*/
|
*/
|
||||||
def createUser(apiKey: String)(user: User
|
def createUser(apiKeyHeader: String)(user: User
|
||||||
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.POST, uri"$baseUrl/user")
|
.method(Method.POST, uri"$baseUrl/user")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
@ -54,12 +54,12 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
def createUsersWithArrayInput(apiKey: String)(user: Seq[User]
|
def createUsersWithArrayInput(apiKeyHeader: String)(user: Seq[User]
|
||||||
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.POST, uri"$baseUrl/user/createWithArray")
|
.method(Method.POST, uri"$baseUrl/user/createWithArray")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
@ -74,12 +74,12 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
def createUsersWithListInput(apiKey: String)(user: Seq[User]
|
def createUsersWithListInput(apiKeyHeader: String)(user: Seq[User]
|
||||||
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.POST, uri"$baseUrl/user/createWithList")
|
.method(Method.POST, uri"$baseUrl/user/createWithList")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
@ -95,12 +95,12 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param username The name that needs to be deleted
|
* @param username The name that needs to be deleted
|
||||||
*/
|
*/
|
||||||
def deleteUser(apiKey: String)(username: String
|
def deleteUser(apiKeyHeader: String)(username: String
|
||||||
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.DELETE, uri"$baseUrl/user/${username}")
|
.method(Method.DELETE, uri"$baseUrl/user/${username}")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,12 +150,12 @@ class UserApi(baseUrl: String) {
|
|||||||
* Available security schemes:
|
* Available security schemes:
|
||||||
* api_key (apiKey)
|
* api_key (apiKey)
|
||||||
*/
|
*/
|
||||||
def logoutUser(apiKey: String)(
|
def logoutUser(apiKeyHeader: String)(
|
||||||
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.GET, uri"$baseUrl/user/logout")
|
.method(Method.GET, uri"$baseUrl/user/logout")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,12 +171,12 @@ class UserApi(baseUrl: String) {
|
|||||||
* @param username name that need to be deleted
|
* @param username name that need to be deleted
|
||||||
* @param user Updated user object
|
* @param user Updated user object
|
||||||
*/
|
*/
|
||||||
def updateUser(apiKey: String)(username: String, user: User
|
def updateUser(apiKeyHeader: String)(username: String, user: User
|
||||||
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
): Request[Either[ResponseException[String, Exception], Unit], Any] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.PUT, uri"$baseUrl/user/${username}")
|
.method(Method.PUT, uri"$baseUrl/user/${username}")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
|
@ -99,11 +99,11 @@ class PetApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param petId ID of pet to return
|
* @param petId ID of pet to return
|
||||||
*/
|
*/
|
||||||
def getPetById(apiKey: String)(petId: Long): Request[Either[ResponseException[String, Exception], Pet]] =
|
def getPetById(apiKeyHeader: String)(petId: Long): Request[Either[ResponseException[String, Exception], Pet]] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.GET, uri"$baseUrl/pet/${petId}")
|
.method(Method.GET, uri"$baseUrl/pet/${petId}")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.response(asJson[Pet])
|
.response(asJson[Pet])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,11 +46,11 @@ class StoreApi(baseUrl: String) {
|
|||||||
* Available security schemes:
|
* Available security schemes:
|
||||||
* api_key (apiKey)
|
* api_key (apiKey)
|
||||||
*/
|
*/
|
||||||
def getInventory(apiKey: String)(): Request[Either[ResponseException[String, Exception], Map[String, Int]]] =
|
def getInventory(apiKeyHeader: String)(): Request[Either[ResponseException[String, Exception], Map[String, Int]]] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.GET, uri"$baseUrl/store/inventory")
|
.method(Method.GET, uri"$baseUrl/store/inventory")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.response(asJson[Map[String, Int]])
|
.response(asJson[Map[String, Int]])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,11 +34,11 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param user Created user object
|
* @param user Created user object
|
||||||
*/
|
*/
|
||||||
def createUser(apiKey: String)(user: User): Request[Either[ResponseException[String, Exception], Unit]] =
|
def createUser(apiKeyHeader: String)(user: User): Request[Either[ResponseException[String, Exception], Unit]] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.POST, uri"$baseUrl/user")
|
.method(Method.POST, uri"$baseUrl/user")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
@ -53,11 +53,11 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
def createUsersWithArrayInput(apiKey: String)(user: Seq[User]): Request[Either[ResponseException[String, Exception], Unit]] =
|
def createUsersWithArrayInput(apiKeyHeader: String)(user: Seq[User]): Request[Either[ResponseException[String, Exception], Unit]] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.POST, uri"$baseUrl/user/createWithArray")
|
.method(Method.POST, uri"$baseUrl/user/createWithArray")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
@ -72,11 +72,11 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param user List of user object
|
* @param user List of user object
|
||||||
*/
|
*/
|
||||||
def createUsersWithListInput(apiKey: String)(user: Seq[User]): Request[Either[ResponseException[String, Exception], Unit]] =
|
def createUsersWithListInput(apiKeyHeader: String)(user: Seq[User]): Request[Either[ResponseException[String, Exception], Unit]] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.POST, uri"$baseUrl/user/createWithList")
|
.method(Method.POST, uri"$baseUrl/user/createWithList")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
@ -92,11 +92,11 @@ class UserApi(baseUrl: String) {
|
|||||||
*
|
*
|
||||||
* @param username The name that needs to be deleted
|
* @param username The name that needs to be deleted
|
||||||
*/
|
*/
|
||||||
def deleteUser(apiKey: String)(username: String): Request[Either[ResponseException[String, Exception], Unit]] =
|
def deleteUser(apiKeyHeader: String)(username: String): Request[Either[ResponseException[String, Exception], Unit]] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.DELETE, uri"$baseUrl/user/${username}")
|
.method(Method.DELETE, uri"$baseUrl/user/${username}")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,11 +144,11 @@ class UserApi(baseUrl: String) {
|
|||||||
* Available security schemes:
|
* Available security schemes:
|
||||||
* api_key (apiKey)
|
* api_key (apiKey)
|
||||||
*/
|
*/
|
||||||
def logoutUser(apiKey: String)(): Request[Either[ResponseException[String, Exception], Unit]] =
|
def logoutUser(apiKeyHeader: String)(): Request[Either[ResponseException[String, Exception], Unit]] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.GET, uri"$baseUrl/user/logout")
|
.method(Method.GET, uri"$baseUrl/user/logout")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -164,11 +164,11 @@ class UserApi(baseUrl: String) {
|
|||||||
* @param username name that need to be deleted
|
* @param username name that need to be deleted
|
||||||
* @param user Updated user object
|
* @param user Updated user object
|
||||||
*/
|
*/
|
||||||
def updateUser(apiKey: String)(username: String, user: User): Request[Either[ResponseException[String, Exception], Unit]] =
|
def updateUser(apiKeyHeader: String)(username: String, user: User): Request[Either[ResponseException[String, Exception], Unit]] =
|
||||||
basicRequest
|
basicRequest
|
||||||
.method(Method.PUT, uri"$baseUrl/user/${username}")
|
.method(Method.PUT, uri"$baseUrl/user/${username}")
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.header("api_key", apiKey)
|
.header("api_key", apiKeyHeader)
|
||||||
.body(user)
|
.body(user)
|
||||||
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
.response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user