From fb986c16c6d8d955f08f3d9e152e484db63a2dcd Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 3 Jul 2021 14:15:47 -0400 Subject: [PATCH 1/4] added authentication switches to support files --- .../codegen/DefaultGenerator.java | 58 +++++++++------ .../codegen/utils/ProcessUtils.java | 72 +++++++++++++++++++ 2 files changed, 107 insertions(+), 23 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index d2e1bb4500d3..f3c2acc6ce52 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -630,6 +630,8 @@ void generateApis(List files, List allOperations, List all allOperations.add(new HashMap<>(operation)); + addAuthenticationSwitches(operation); + for (String templateName : config.apiTemplateFiles().keySet()) { String filename = config.apiFilename(templateName, tag); File written = processTemplateToFile(operation, templateName, filename, generateApis, CodegenConstants.APIS); @@ -779,30 +781,10 @@ Map buildSupportFileBundle(List allOperations, List securitySchemeMap = openAPI.getComponents() != null ? openAPI.getComponents().getSecuritySchemes() : null; - List authMethods = config.fromSecurity(securitySchemeMap); - if (authMethods != null && !authMethods.isEmpty()) { - bundle.put("authMethods", authMethods); - bundle.put("hasAuthMethods", true); - - if (ProcessUtils.hasOAuthMethods(authMethods)) { - bundle.put("hasOAuthMethods", true); - bundle.put("oauthMethods", ProcessUtils.getOAuthMethods(authMethods)); - } - if (ProcessUtils.hasHttpBearerMethods(authMethods)) { - bundle.put("hasHttpBearerMethods", true); - } - if (ProcessUtils.hasHttpSignatureMethods(authMethods)) { - bundle.put("hasHttpSignatureMethods", true); - } - if (ProcessUtils.hasHttpBasicMethods(authMethods)) { - bundle.put("hasHttpBasicMethods", true); - } - if (ProcessUtils.hasApiKeyMethods(authMethods)) { - bundle.put("hasApiKeyMethods", true); - } - } + addAuthenticationSwitches(bundle); List servers = config.fromServers(openAPI.getServers()); if (servers != null && !servers.isEmpty()) { @@ -830,6 +812,36 @@ Map buildSupportFileBundle(List allOperations, List bundle){ + Map securitySchemeMap = openAPI.getComponents() != null ? openAPI.getComponents().getSecuritySchemes() : null; + List authMethods = config.fromSecurity(securitySchemeMap); + if (authMethods != null && !authMethods.isEmpty()) { + bundle.put("authMethods", authMethods); + bundle.put("hasAuthMethods", true); + + if (ProcessUtils.hasOAuthMethods(authMethods)) { + bundle.put("hasOAuthMethods", true); + bundle.put("oauthMethods", ProcessUtils.getOAuthMethods(authMethods)); + } + if (ProcessUtils.hasHttpBearerMethods(authMethods)) { + bundle.put("hasHttpBearerMethods", true); + bundle.put("httpBearerMethods", ProcessUtils.getHttpBearerMethods(authMethods)); + } + if (ProcessUtils.hasHttpSignatureMethods(authMethods)) { + bundle.put("hasHttpSignatureMethods", true); + bundle.put("httpSignatureMethods", ProcessUtils.getHttpSignatureMethods(authMethods)); + } + if (ProcessUtils.hasHttpBasicMethods(authMethods)) { + bundle.put("hasHttpBasicMethods", true); + bundle.put("httpBasicMethods", ProcessUtils.getHttpBasicMethods(authMethods)); + } + if (ProcessUtils.hasApiKeyMethods(authMethods)) { + bundle.put("hasApiKeyMethods", true); + bundle.put("apiKeyMethods", ProcessUtils.getApiKeyMethods(authMethods)); + } + } + } + @Override public List generate() { if (openAPI == null) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ProcessUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ProcessUtils.java index 167c7d21124d..9042eb92b395 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ProcessUtils.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ProcessUtils.java @@ -63,6 +63,24 @@ public static boolean hasHttpBasicMethods(List authMethods) { return false; } + /** + * Returns a list of OAS Codegen security objects + * + * @param authMethods List of auth methods. + * @return A list of OAS Codegen security objects + */ + public static List getHttpBasicMethods(List authMethods) { + List httpBasicMethods = new ArrayList<>(); + + for (CodegenSecurity cs : authMethods) { + if (Boolean.TRUE.equals(cs.isBasicBasic)) { + httpBasicMethods.add(cs); + } + } + + return httpBasicMethods; + } + /** * Returns true if the specified OAS model has at least one operation with API keys. * @@ -80,6 +98,24 @@ public static boolean hasApiKeyMethods(List authMethods) { return false; } + /** + * Returns a list of OAS Codegen security objects + * + * @param authMethods List of auth methods. + * @return A list of OAS Codegen security objects + */ + public static List getApiKeyMethods(List authMethods) { + List apiKeyMethods = new ArrayList<>(); + + for (CodegenSecurity cs : authMethods) { + if (Boolean.TRUE.equals(cs.isApiKey)) { + apiKeyMethods.add(cs); + } + } + + return apiKeyMethods; + } + /** * Returns true if the specified OAS model has at least one operation with the HTTP basic * security scheme. @@ -99,6 +135,24 @@ public static boolean hasHttpSignatureMethods(List authMethods) return false; } + /** + * Returns a list of OAS Codegen security objects + * + * @param authMethods List of auth methods. + * @return A list of OAS Codegen security objects + */ + public static List getHttpSignatureMethods(List authMethods) { + List httpSignatureMethods = new ArrayList<>(); + + for (CodegenSecurity cs : authMethods) { + if (Boolean.TRUE.equals(cs.isHttpSignature)) { + httpSignatureMethods.add(cs); + } + } + + return httpSignatureMethods; + } + /** * Returns true if the specified OAS model has at least one operation with HTTP bearer. * @@ -116,6 +170,24 @@ public static boolean hasHttpBearerMethods(List authMethods) { return false; } + /** + * Returns a list of Bearer Codegen security objects + * + * @param authMethods List of auth methods. + * @return A list of Bearer Codegen security objects + */ + public static List getHttpBearerMethods(List authMethods) { + List httpBearerMethods = new ArrayList<>(); + + for (CodegenSecurity cs : authMethods) { + if (Boolean.TRUE.equals(cs.isBasicBearer)) { + httpBearerMethods.add(cs); + } + } + + return httpBearerMethods; + } + /** * Returns true if the specified OAS model has at least one operation with OAuth. * From fccac46045334b6e218a46db61f45156fe3952fd Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 3 Jul 2021 14:27:53 -0400 Subject: [PATCH 2/4] build samples --- .../typescript-node/default/api/petApi.ts | 2 +- .../typescript-node/default/api/storeApi.ts | 5 + .../typescript-node/default/api/userApi.ts | 8 + .../typescript-node/npm/api/petApi.ts | 2 +- .../typescript-node/npm/api/storeApi.ts | 5 + .../typescript-node/npm/api/userApi.ts | 8 + .../org/openapitools/server/apis/PetApi.kt | 274 +++++++++--------- .../org/openapitools/server/apis/StoreApi.kt | 156 +++++----- .../org/openapitools/server/apis/UserApi.kt | 166 +++++------ .../php-slim4/.openapi-generator/FILES | 3 + 10 files changed, 329 insertions(+), 300 deletions(-) diff --git a/samples/client/petstore/typescript-node/default/api/petApi.ts b/samples/client/petstore/typescript-node/default/api/petApi.ts index 87004460f28b..1dfd5447c6f2 100644 --- a/samples/client/petstore/typescript-node/default/api/petApi.ts +++ b/samples/client/petstore/typescript-node/default/api/petApi.ts @@ -40,8 +40,8 @@ export class PetApi { protected authentications = { 'default': new VoidAuth(), - 'petstore_auth': new OAuth(), 'api_key': new ApiKeyAuth('header', 'api_key'), + 'petstore_auth': new OAuth(), } protected interceptors: Interceptor[] = []; diff --git a/samples/client/petstore/typescript-node/default/api/storeApi.ts b/samples/client/petstore/typescript-node/default/api/storeApi.ts index 5935259f0b8b..500c63256647 100644 --- a/samples/client/petstore/typescript-node/default/api/storeApi.ts +++ b/samples/client/petstore/typescript-node/default/api/storeApi.ts @@ -40,6 +40,7 @@ export class StoreApi { protected authentications = { 'default': new VoidAuth(), 'api_key': new ApiKeyAuth('header', 'api_key'), + 'petstore_auth': new OAuth(), } protected interceptors: Interceptor[] = []; @@ -85,6 +86,10 @@ export class StoreApi { (this.authentications as any)[StoreApiApiKeys[key]].apiKey = value; } + set accessToken(token: string) { + this.authentications.petstore_auth.accessToken = token; + } + public addInterceptor(interceptor: Interceptor) { this.interceptors.push(interceptor); } diff --git a/samples/client/petstore/typescript-node/default/api/userApi.ts b/samples/client/petstore/typescript-node/default/api/userApi.ts index ab4675de90a1..3a29f079eafb 100644 --- a/samples/client/petstore/typescript-node/default/api/userApi.ts +++ b/samples/client/petstore/typescript-node/default/api/userApi.ts @@ -18,6 +18,7 @@ import http from 'http'; import { User } from '../model/user'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; +import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; import { HttpError, RequestFile } from './apis'; @@ -28,6 +29,7 @@ let defaultBasePath = 'http://petstore.swagger.io/v2'; // =============================================== export enum UserApiApiKeys { + api_key, } export class UserApi { @@ -37,6 +39,8 @@ export class UserApi { protected authentications = { 'default': new VoidAuth(), + 'api_key': new ApiKeyAuth('header', 'api_key'), + 'petstore_auth': new OAuth(), } protected interceptors: Interceptor[] = []; @@ -82,6 +86,10 @@ export class UserApi { (this.authentications as any)[UserApiApiKeys[key]].apiKey = value; } + set accessToken(token: string) { + this.authentications.petstore_auth.accessToken = token; + } + public addInterceptor(interceptor: Interceptor) { this.interceptors.push(interceptor); } diff --git a/samples/client/petstore/typescript-node/npm/api/petApi.ts b/samples/client/petstore/typescript-node/npm/api/petApi.ts index 87004460f28b..1dfd5447c6f2 100644 --- a/samples/client/petstore/typescript-node/npm/api/petApi.ts +++ b/samples/client/petstore/typescript-node/npm/api/petApi.ts @@ -40,8 +40,8 @@ export class PetApi { protected authentications = { 'default': new VoidAuth(), - 'petstore_auth': new OAuth(), 'api_key': new ApiKeyAuth('header', 'api_key'), + 'petstore_auth': new OAuth(), } protected interceptors: Interceptor[] = []; diff --git a/samples/client/petstore/typescript-node/npm/api/storeApi.ts b/samples/client/petstore/typescript-node/npm/api/storeApi.ts index 5935259f0b8b..500c63256647 100644 --- a/samples/client/petstore/typescript-node/npm/api/storeApi.ts +++ b/samples/client/petstore/typescript-node/npm/api/storeApi.ts @@ -40,6 +40,7 @@ export class StoreApi { protected authentications = { 'default': new VoidAuth(), 'api_key': new ApiKeyAuth('header', 'api_key'), + 'petstore_auth': new OAuth(), } protected interceptors: Interceptor[] = []; @@ -85,6 +86,10 @@ export class StoreApi { (this.authentications as any)[StoreApiApiKeys[key]].apiKey = value; } + set accessToken(token: string) { + this.authentications.petstore_auth.accessToken = token; + } + public addInterceptor(interceptor: Interceptor) { this.interceptors.push(interceptor); } diff --git a/samples/client/petstore/typescript-node/npm/api/userApi.ts b/samples/client/petstore/typescript-node/npm/api/userApi.ts index ab4675de90a1..3a29f079eafb 100644 --- a/samples/client/petstore/typescript-node/npm/api/userApi.ts +++ b/samples/client/petstore/typescript-node/npm/api/userApi.ts @@ -18,6 +18,7 @@ import http from 'http'; import { User } from '../model/user'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; +import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; import { HttpError, RequestFile } from './apis'; @@ -28,6 +29,7 @@ let defaultBasePath = 'http://petstore.swagger.io/v2'; // =============================================== export enum UserApiApiKeys { + api_key, } export class UserApi { @@ -37,6 +39,8 @@ export class UserApi { protected authentications = { 'default': new VoidAuth(), + 'api_key': new ApiKeyAuth('header', 'api_key'), + 'petstore_auth': new OAuth(), } protected interceptors: Interceptor[] = []; @@ -82,6 +86,10 @@ export class UserApi { (this.authentications as any)[UserApiApiKeys[key]].apiKey = value; } + set accessToken(token: string) { + this.authentications.petstore_auth.accessToken = token; + } + public addInterceptor(interceptor: Interceptor) { this.interceptors.push(interceptor); } diff --git a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/PetApi.kt b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/PetApi.kt index 9226541eb34e..83c189c23582 100644 --- a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/PetApi.kt +++ b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/PetApi.kt @@ -1,68 +1,68 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* The version of the OpenAPI document: 1.0.0 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ -package org.openapitools.server.apis - -import com.google.gson.Gson -import io.ktor.application.call -import io.ktor.auth.UserIdPrincipal -import io.ktor.auth.authentication -import io.ktor.auth.authenticate -import io.ktor.auth.OAuthAccessTokenResponse -import io.ktor.auth.OAuthServerSettings -import io.ktor.http.ContentType -import io.ktor.http.HttpStatusCode -import io.ktor.response.respond -import io.ktor.response.respondText -import io.ktor.routing.Route -import org.openapitools.server.Paths -import io.ktor.locations.KtorExperimentalLocationsAPI -import io.ktor.locations.delete -import io.ktor.locations.get -import io.ktor.locations.post -import io.ktor.locations.put -import io.ktor.locations.options -import io.ktor.locations.head - -import org.openapitools.server.infrastructure.ApiPrincipal - - -import org.openapitools.server.models.ApiResponse -import org.openapitools.server.models.Pet - -@KtorExperimentalLocationsAPI -fun Route.PetApi() { - val gson = Gson() - val empty = mutableMapOf() - authenticate("petstore_auth") { - post { - val principal = call.authentication.principal()!! - - call.respond(HttpStatusCode.NotImplemented) - } - } - - authenticate("petstore_auth") { - delete { - val principal = call.authentication.principal()!! - - call.respond(HttpStatusCode.NotImplemented) - } - } - - authenticate("petstore_auth") { - get { - val principal = call.authentication.principal()!! - - val exampleContentType = "application/json" +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.server.apis + +import com.google.gson.Gson +import io.ktor.application.call +import io.ktor.auth.UserIdPrincipal +import io.ktor.auth.authentication +import io.ktor.auth.authenticate +import io.ktor.auth.OAuthAccessTokenResponse +import io.ktor.auth.OAuthServerSettings +import io.ktor.http.ContentType +import io.ktor.http.HttpStatusCode +import io.ktor.response.respond +import io.ktor.response.respondText +import io.ktor.routing.Route +import org.openapitools.server.Paths +import io.ktor.locations.KtorExperimentalLocationsAPI +import io.ktor.locations.delete +import io.ktor.locations.get +import io.ktor.locations.post +import io.ktor.locations.put +import io.ktor.locations.options +import io.ktor.locations.head + +import org.openapitools.server.infrastructure.ApiPrincipal + + +import org.openapitools.server.models.ApiResponse +import org.openapitools.server.models.Pet + +@KtorExperimentalLocationsAPI +fun Route.PetApi() { + val gson = Gson() + val empty = mutableMapOf() + authenticate("petstore_auth") { + post { + val principal = call.authentication.principal()!! + + call.respond(HttpStatusCode.NotImplemented) + } + } + + authenticate("petstore_auth") { + delete { + val principal = call.authentication.principal()!! + + call.respond(HttpStatusCode.NotImplemented) + } + } + + authenticate("petstore_auth") { + get { + val principal = call.authentication.principal()!! + + val exampleContentType = "application/json" val exampleContentString = """{ "photoUrls" : [ "photoUrls", "photoUrls" ], "name" : "doggie", @@ -79,21 +79,21 @@ fun Route.PetApi() { "id" : 1 } ], "status" : "available" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - } - - authenticate("petstore_auth") { - get { - val principal = call.authentication.principal()!! - - val exampleContentType = "application/json" + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + } + + authenticate("petstore_auth") { + get { + val principal = call.authentication.principal()!! + + val exampleContentType = "application/json" val exampleContentString = """{ "photoUrls" : [ "photoUrls", "photoUrls" ], "name" : "doggie", @@ -110,21 +110,21 @@ fun Route.PetApi() { "id" : 1 } ], "status" : "available" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - } - - authenticate("api_key") { - get { - val principal = call.authentication.principal()!! - - val exampleContentType = "application/json" + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + } + + authenticate("api_key") { + get { + val principal = call.authentication.principal()!! + + val exampleContentType = "application/json" val exampleContentString = """{ "photoUrls" : [ "photoUrls", "photoUrls" ], "name" : "doggie", @@ -141,49 +141,49 @@ fun Route.PetApi() { "id" : 1 } ], "status" : "available" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - } - - authenticate("petstore_auth") { - put { - val principal = call.authentication.principal()!! - - call.respond(HttpStatusCode.NotImplemented) - } - } - - authenticate("petstore_auth") { - post { - val principal = call.authentication.principal()!! - - call.respond(HttpStatusCode.NotImplemented) - } - } - - authenticate("petstore_auth") { - post { - val principal = call.authentication.principal()!! - - val exampleContentType = "application/json" + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + } + + authenticate("petstore_auth") { + put { + val principal = call.authentication.principal()!! + + call.respond(HttpStatusCode.NotImplemented) + } + } + + authenticate("petstore_auth") { + post { + val principal = call.authentication.principal()!! + + call.respond(HttpStatusCode.NotImplemented) + } + } + + authenticate("petstore_auth") { + post { + val principal = call.authentication.principal()!! + + val exampleContentType = "application/json" val exampleContentString = """{ "code" : 0, "type" : "type", "message" : "message" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - } - -} + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + } + +} diff --git a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt index 2e5f4ab8b96c..72e82afe2665 100644 --- a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt +++ b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt @@ -1,60 +1,60 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* The version of the OpenAPI document: 1.0.0 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ -package org.openapitools.server.apis - -import com.google.gson.Gson -import io.ktor.application.call -import io.ktor.auth.UserIdPrincipal -import io.ktor.auth.authentication -import io.ktor.auth.authenticate -import io.ktor.auth.OAuthAccessTokenResponse -import io.ktor.auth.OAuthServerSettings -import io.ktor.http.ContentType -import io.ktor.http.HttpStatusCode -import io.ktor.response.respond -import io.ktor.response.respondText -import io.ktor.routing.Route -import org.openapitools.server.Paths -import io.ktor.locations.KtorExperimentalLocationsAPI -import io.ktor.locations.delete -import io.ktor.locations.get -import io.ktor.locations.post -import io.ktor.locations.put -import io.ktor.locations.options -import io.ktor.locations.head - -import org.openapitools.server.infrastructure.ApiPrincipal - - -import org.openapitools.server.models.Order - -@KtorExperimentalLocationsAPI -fun Route.StoreApi() { - val gson = Gson() - val empty = mutableMapOf() - delete { - call.respond(HttpStatusCode.NotImplemented) - } - - authenticate("api_key") { - get { - val principal = call.authentication.principal()!! - - call.respond(HttpStatusCode.NotImplemented) - } - } - - get { - val exampleContentType = "application/json" +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.server.apis + +import com.google.gson.Gson +import io.ktor.application.call +import io.ktor.auth.UserIdPrincipal +import io.ktor.auth.authentication +import io.ktor.auth.authenticate +import io.ktor.auth.OAuthAccessTokenResponse +import io.ktor.auth.OAuthServerSettings +import io.ktor.http.ContentType +import io.ktor.http.HttpStatusCode +import io.ktor.response.respond +import io.ktor.response.respondText +import io.ktor.routing.Route +import org.openapitools.server.Paths +import io.ktor.locations.KtorExperimentalLocationsAPI +import io.ktor.locations.delete +import io.ktor.locations.get +import io.ktor.locations.post +import io.ktor.locations.put +import io.ktor.locations.options +import io.ktor.locations.head + +import org.openapitools.server.infrastructure.ApiPrincipal + + +import org.openapitools.server.models.Order + +@KtorExperimentalLocationsAPI +fun Route.StoreApi() { + val gson = Gson() + val empty = mutableMapOf() + delete { + call.respond(HttpStatusCode.NotImplemented) + } + + authenticate("api_key") { + get { + val principal = call.authentication.principal()!! + + call.respond(HttpStatusCode.NotImplemented) + } + } + + get { + val exampleContentType = "application/json" val exampleContentString = """{ "petId" : 6, "quantity" : 1, @@ -62,17 +62,17 @@ fun Route.StoreApi() { "shipDate" : "2000-01-23T04:56:07.000+00:00", "complete" : false, "status" : "placed" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - - post { - val exampleContentType = "application/json" + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + + post { + val exampleContentType = "application/json" val exampleContentString = """{ "petId" : 6, "quantity" : 1, @@ -80,13 +80,13 @@ fun Route.StoreApi() { "shipDate" : "2000-01-23T04:56:07.000+00:00", "complete" : false, "status" : "placed" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - -} + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + +} diff --git a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/UserApi.kt b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/UserApi.kt index e248d75ae0cc..6b902d35c0ae 100644 --- a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/UserApi.kt +++ b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/UserApi.kt @@ -1,64 +1,64 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* The version of the OpenAPI document: 1.0.0 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ -package org.openapitools.server.apis - -import com.google.gson.Gson -import io.ktor.application.call -import io.ktor.auth.UserIdPrincipal -import io.ktor.auth.authentication -import io.ktor.auth.authenticate -import io.ktor.auth.OAuthAccessTokenResponse -import io.ktor.auth.OAuthServerSettings -import io.ktor.http.ContentType -import io.ktor.http.HttpStatusCode -import io.ktor.response.respond -import io.ktor.response.respondText -import io.ktor.routing.Route -import org.openapitools.server.Paths -import io.ktor.locations.KtorExperimentalLocationsAPI -import io.ktor.locations.delete -import io.ktor.locations.get -import io.ktor.locations.post -import io.ktor.locations.put -import io.ktor.locations.options -import io.ktor.locations.head - -import org.openapitools.server.infrastructure.ApiPrincipal - - -import org.openapitools.server.models.User - -@KtorExperimentalLocationsAPI -fun Route.UserApi() { - val gson = Gson() - val empty = mutableMapOf() - post { - call.respond(HttpStatusCode.NotImplemented) - } - - post { - call.respond(HttpStatusCode.NotImplemented) - } - - post { - call.respond(HttpStatusCode.NotImplemented) - } - - delete { - call.respond(HttpStatusCode.NotImplemented) - } - - get { - val exampleContentType = "application/json" +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* The version of the OpenAPI document: 1.0.0 +* +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +package org.openapitools.server.apis + +import com.google.gson.Gson +import io.ktor.application.call +import io.ktor.auth.UserIdPrincipal +import io.ktor.auth.authentication +import io.ktor.auth.authenticate +import io.ktor.auth.OAuthAccessTokenResponse +import io.ktor.auth.OAuthServerSettings +import io.ktor.http.ContentType +import io.ktor.http.HttpStatusCode +import io.ktor.response.respond +import io.ktor.response.respondText +import io.ktor.routing.Route +import org.openapitools.server.Paths +import io.ktor.locations.KtorExperimentalLocationsAPI +import io.ktor.locations.delete +import io.ktor.locations.get +import io.ktor.locations.post +import io.ktor.locations.put +import io.ktor.locations.options +import io.ktor.locations.head + +import org.openapitools.server.infrastructure.ApiPrincipal + + +import org.openapitools.server.models.User + +@KtorExperimentalLocationsAPI +fun Route.UserApi() { + val gson = Gson() + val empty = mutableMapOf() + post { + call.respond(HttpStatusCode.NotImplemented) + } + + post { + call.respond(HttpStatusCode.NotImplemented) + } + + post { + call.respond(HttpStatusCode.NotImplemented) + } + + delete { + call.respond(HttpStatusCode.NotImplemented) + } + + get { + val exampleContentType = "application/json" val exampleContentString = """{ "firstName" : "firstName", "lastName" : "lastName", @@ -68,25 +68,25 @@ fun Route.UserApi() { "id" : 0, "email" : "email", "username" : "username" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - - get { - call.respond(HttpStatusCode.NotImplemented) - } - - get { - call.respond(HttpStatusCode.NotImplemented) - } - - put { - call.respond(HttpStatusCode.NotImplemented) - } - -} + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + + get { + call.respond(HttpStatusCode.NotImplemented) + } + + get { + call.respond(HttpStatusCode.NotImplemented) + } + + put { + call.respond(HttpStatusCode.NotImplemented) + } + +} diff --git a/samples/server/petstore/php-slim4/.openapi-generator/FILES b/samples/server/petstore/php-slim4/.openapi-generator/FILES index 463e80a1257a..6d7926cf5105 100644 --- a/samples/server/petstore/php-slim4/.openapi-generator/FILES +++ b/samples/server/petstore/php-slim4/.openapi-generator/FILES @@ -25,6 +25,9 @@ lib/Auth/AbstractAuthenticator.php lib/Auth/AbstractAuthenticator.php lib/Auth/AbstractAuthenticator.php lib/Auth/AbstractAuthenticator.php +lib/Auth/AbstractAuthenticator.php +lib/Auth/AbstractAuthenticator.php +lib/Auth/AbstractAuthenticator.php lib/BaseModel.php lib/Middleware/JsonBodyParserMiddleware.php lib/Model/ApiResponse.php From c269f7baa3824fe7140efe6dea837af417bfda00 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 3 Jul 2021 15:13:11 -0400 Subject: [PATCH 3/4] build samples --- .../erlang-server/src/openapi_pet_handler.erl | 4 +- .../src/openapi_store_handler.erl | 4 +- .../src/openapi_user_handler.erl | 4 +- .../org/openapitools/server/apis/PetApi.kt | 212 ++++++------------ .../org/openapitools/server/apis/StoreApi.kt | 102 ++------- .../org/openapitools/server/apis/UserApi.kt | 108 ++------- 6 files changed, 124 insertions(+), 310 deletions(-) diff --git a/samples/server/petstore/erlang-server/src/openapi_pet_handler.erl b/samples/server/petstore/erlang-server/src/openapi_pet_handler.erl index a6cbaab177c1..9e527a76195c 100644 --- a/samples/server/petstore/erlang-server/src/openapi_pet_handler.erl +++ b/samples/server/petstore/erlang-server/src/openapi_pet_handler.erl @@ -272,7 +272,9 @@ is_authorized( {false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State} end; is_authorized(Req, State) -> - {true, Req, State}. + {{false, <<"">>}, Req, State}. +is_authorized(Req, State) -> + {{false, <<"">>}, Req, State}. -spec content_types_accepted(Req :: cowboy_req:req(), State :: state()) -> { diff --git a/samples/server/petstore/erlang-server/src/openapi_store_handler.erl b/samples/server/petstore/erlang-server/src/openapi_store_handler.erl index 98341c066c28..2a0196134242 100644 --- a/samples/server/petstore/erlang-server/src/openapi_store_handler.erl +++ b/samples/server/petstore/erlang-server/src/openapi_store_handler.erl @@ -107,7 +107,9 @@ is_authorized( {false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State} end; is_authorized(Req, State) -> - {true, Req, State}. + {{false, <<"">>}, Req, State}. +is_authorized(Req, State) -> + {{false, <<"">>}, Req, State}. -spec content_types_accepted(Req :: cowboy_req:req(), State :: state()) -> { diff --git a/samples/server/petstore/erlang-server/src/openapi_user_handler.erl b/samples/server/petstore/erlang-server/src/openapi_user_handler.erl index ad9f11d7300b..00d5819e3236 100644 --- a/samples/server/petstore/erlang-server/src/openapi_user_handler.erl +++ b/samples/server/petstore/erlang-server/src/openapi_user_handler.erl @@ -234,7 +234,9 @@ is_authorized( {false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State} end; is_authorized(Req, State) -> - {true, Req, State}. + {{false, <<"">>}, Req, State}. +is_authorized(Req, State) -> + {{false, <<"">>}, Req, State}. -spec content_types_accepted(Req :: cowboy_req:req(), State :: state()) -> { diff --git a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/PetApi.kt b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/PetApi.kt index e31d10f77a7a..95f5d7fb8808 100644 --- a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/PetApi.kt +++ b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/PetApi.kt @@ -1,70 +1,3 @@ -<<<<<<< HEAD -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* The version of the OpenAPI document: 1.0.0 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ -package org.openapitools.server.apis - -import com.google.gson.Gson -import io.ktor.application.call -import io.ktor.auth.UserIdPrincipal -import io.ktor.auth.authentication -import io.ktor.auth.authenticate -import io.ktor.auth.OAuthAccessTokenResponse -import io.ktor.auth.OAuthServerSettings -import io.ktor.http.ContentType -import io.ktor.http.HttpStatusCode -import io.ktor.response.respond -import io.ktor.response.respondText -import io.ktor.routing.Route -import org.openapitools.server.Paths -import io.ktor.locations.KtorExperimentalLocationsAPI -import io.ktor.locations.delete -import io.ktor.locations.get -import io.ktor.locations.post -import io.ktor.locations.put -import io.ktor.locations.options -import io.ktor.locations.head - -import org.openapitools.server.infrastructure.ApiPrincipal - - -import org.openapitools.server.models.ApiResponse -import org.openapitools.server.models.Pet - -@KtorExperimentalLocationsAPI -fun Route.PetApi() { - val gson = Gson() - val empty = mutableMapOf() - authenticate("petstore_auth") { - post { - val principal = call.authentication.principal()!! - - call.respond(HttpStatusCode.NotImplemented) - } - } - - authenticate("petstore_auth") { - delete { - val principal = call.authentication.principal()!! - - call.respond(HttpStatusCode.NotImplemented) - } - } - - authenticate("petstore_auth") { - get { - val principal = call.authentication.principal()!! - - val exampleContentType = "application/json" -======= /** * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. @@ -116,7 +49,6 @@ fun Route.PetApi() { val principal = call.authentication.principal()!! val exampleContentType = "application/json" ->>>>>>> master val exampleContentString = """{ "photoUrls" : [ "photoUrls", "photoUrls" ], "name" : "doggie", @@ -133,21 +65,21 @@ fun Route.PetApi() { "id" : 1 } ], "status" : "available" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - } - - authenticate("petstore_auth") { - get { - val principal = call.authentication.principal()!! - - val exampleContentType = "application/json" + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + } + + authenticate("petstore_auth") { + get { + val principal = call.authentication.principal()!! + + val exampleContentType = "application/json" val exampleContentString = """{ "photoUrls" : [ "photoUrls", "photoUrls" ], "name" : "doggie", @@ -164,21 +96,21 @@ fun Route.PetApi() { "id" : 1 } ], "status" : "available" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - } - - authenticate("api_key") { - get { - val principal = call.authentication.principal()!! - - val exampleContentType = "application/json" + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + } + + authenticate("api_key") { + get { + val principal = call.authentication.principal()!! + + val exampleContentType = "application/json" val exampleContentString = """{ "photoUrls" : [ "photoUrls", "photoUrls" ], "name" : "doggie", @@ -195,49 +127,49 @@ fun Route.PetApi() { "id" : 1 } ], "status" : "available" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - } - - authenticate("petstore_auth") { - put { - val principal = call.authentication.principal()!! - - call.respond(HttpStatusCode.NotImplemented) - } - } - - authenticate("petstore_auth") { - post { - val principal = call.authentication.principal()!! - - call.respond(HttpStatusCode.NotImplemented) - } - } - - authenticate("petstore_auth") { - post { - val principal = call.authentication.principal()!! - - val exampleContentType = "application/json" + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + } + + authenticate("petstore_auth") { + put { + val principal = call.authentication.principal()!! + + call.respond(HttpStatusCode.NotImplemented) + } + } + + authenticate("petstore_auth") { + post { + val principal = call.authentication.principal()!! + + call.respond(HttpStatusCode.NotImplemented) + } + } + + authenticate("petstore_auth") { + post { + val principal = call.authentication.principal()!! + + val exampleContentType = "application/json" val exampleContentString = """{ "code" : 0, "type" : "type", "message" : "message" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - } - -} + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + } + +} diff --git a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt index e7ceb08a562a..b195797a0203 100644 --- a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt +++ b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt @@ -1,62 +1,3 @@ -<<<<<<< HEAD -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* The version of the OpenAPI document: 1.0.0 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ -package org.openapitools.server.apis - -import com.google.gson.Gson -import io.ktor.application.call -import io.ktor.auth.UserIdPrincipal -import io.ktor.auth.authentication -import io.ktor.auth.authenticate -import io.ktor.auth.OAuthAccessTokenResponse -import io.ktor.auth.OAuthServerSettings -import io.ktor.http.ContentType -import io.ktor.http.HttpStatusCode -import io.ktor.response.respond -import io.ktor.response.respondText -import io.ktor.routing.Route -import org.openapitools.server.Paths -import io.ktor.locations.KtorExperimentalLocationsAPI -import io.ktor.locations.delete -import io.ktor.locations.get -import io.ktor.locations.post -import io.ktor.locations.put -import io.ktor.locations.options -import io.ktor.locations.head - -import org.openapitools.server.infrastructure.ApiPrincipal - - -import org.openapitools.server.models.Order - -@KtorExperimentalLocationsAPI -fun Route.StoreApi() { - val gson = Gson() - val empty = mutableMapOf() - delete { - call.respond(HttpStatusCode.NotImplemented) - } - - authenticate("api_key") { - get { - val principal = call.authentication.principal()!! - - call.respond(HttpStatusCode.NotImplemented) - } - } - - get { - val exampleContentType = "application/json" -======= /** * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. @@ -100,7 +41,6 @@ fun Route.StoreApi() { get { val exampleContentType = "application/json" ->>>>>>> master val exampleContentString = """{ "petId" : 6, "quantity" : 1, @@ -108,17 +48,17 @@ fun Route.StoreApi() { "shipDate" : "2000-01-23T04:56:07.000+00:00", "complete" : false, "status" : "placed" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - - post { - val exampleContentType = "application/json" + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + + post { + val exampleContentType = "application/json" val exampleContentString = """{ "petId" : 6, "quantity" : 1, @@ -126,13 +66,13 @@ fun Route.StoreApi() { "shipDate" : "2000-01-23T04:56:07.000+00:00", "complete" : false, "status" : "placed" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - -} + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + +} diff --git a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/UserApi.kt b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/UserApi.kt index 1a482ab5815a..1871c4b30975 100644 --- a/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/UserApi.kt +++ b/samples/server/petstore/kotlin-server/ktor/src/main/kotlin/org/openapitools/server/apis/UserApi.kt @@ -1,66 +1,3 @@ -<<<<<<< HEAD -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* The version of the OpenAPI document: 1.0.0 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ -package org.openapitools.server.apis - -import com.google.gson.Gson -import io.ktor.application.call -import io.ktor.auth.UserIdPrincipal -import io.ktor.auth.authentication -import io.ktor.auth.authenticate -import io.ktor.auth.OAuthAccessTokenResponse -import io.ktor.auth.OAuthServerSettings -import io.ktor.http.ContentType -import io.ktor.http.HttpStatusCode -import io.ktor.response.respond -import io.ktor.response.respondText -import io.ktor.routing.Route -import org.openapitools.server.Paths -import io.ktor.locations.KtorExperimentalLocationsAPI -import io.ktor.locations.delete -import io.ktor.locations.get -import io.ktor.locations.post -import io.ktor.locations.put -import io.ktor.locations.options -import io.ktor.locations.head - -import org.openapitools.server.infrastructure.ApiPrincipal - - -import org.openapitools.server.models.User - -@KtorExperimentalLocationsAPI -fun Route.UserApi() { - val gson = Gson() - val empty = mutableMapOf() - post { - call.respond(HttpStatusCode.NotImplemented) - } - - post { - call.respond(HttpStatusCode.NotImplemented) - } - - post { - call.respond(HttpStatusCode.NotImplemented) - } - - delete { - call.respond(HttpStatusCode.NotImplemented) - } - - get { - val exampleContentType = "application/json" -======= /** * OpenAPI Petstore * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. @@ -108,7 +45,6 @@ fun Route.UserApi() { get { val exampleContentType = "application/json" ->>>>>>> master val exampleContentString = """{ "firstName" : "firstName", "lastName" : "lastName", @@ -118,25 +54,25 @@ fun Route.UserApi() { "id" : 0, "email" : "email", "username" : "username" - }""" - - when (exampleContentType) { - "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) - "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) - else -> call.respondText(exampleContentString) - } - } - - get { - call.respond(HttpStatusCode.NotImplemented) - } - - get { - call.respond(HttpStatusCode.NotImplemented) - } - - put { - call.respond(HttpStatusCode.NotImplemented) - } - -} + }""" + + when (exampleContentType) { + "application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class.java)) + "application/xml" -> call.respondText(exampleContentString, ContentType.Text.Xml) + else -> call.respondText(exampleContentString) + } + } + + get { + call.respond(HttpStatusCode.NotImplemented) + } + + get { + call.respond(HttpStatusCode.NotImplemented) + } + + put { + call.respond(HttpStatusCode.NotImplemented) + } + +} From 18ae90aa09a2a65146b841bb0eee544d9e1fa98e Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sun, 4 Jul 2021 12:03:53 -0400 Subject: [PATCH 4/4] added documentation --- .../org/openapitools/codegen/DefaultGenerator.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index f3c2acc6ce52..404c49fd0d2f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -812,6 +812,18 @@ Map buildSupportFileBundle(List allOperations, List + * Examples: + *

+ * boolean hasOAuthMethods + *

+ * List<CodegenSecurity> oauthMethods + * + * @param bundle the map which the booleans and collections will be added + */ void addAuthenticationSwitches(Map bundle){ Map securitySchemeMap = openAPI.getComponents() != null ? openAPI.getComponents().getSecuritySchemes() : null; List authMethods = config.fromSecurity(securitySchemeMap);