Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Kotlin-spring] add springdoc config (#12377)
* Adding Springdoc config to Kotlin-Spring * Updating relevant samples * Updating unrelated samples
- Loading branch information
Showing
9 changed files
with
152 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
.../openapi-generator/src/main/resources/kotlin-spring/springdocDocumentationConfig.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package {{basePackage}} | ||
|
||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
import io.swagger.v3.oas.models.OpenAPI | ||
import io.swagger.v3.oas.models.info.Info | ||
import io.swagger.v3.oas.models.info.Contact | ||
import io.swagger.v3.oas.models.info.License | ||
import io.swagger.v3.oas.models.Components | ||
import io.swagger.v3.oas.models.security.SecurityScheme | ||
|
||
{{>generatedAnnotation}} | ||
@Configuration | ||
class SpringDocConfiguration { | ||
@Bean | ||
fun apiInfo(): OpenAPI { | ||
return OpenAPI() | ||
.info( | ||
Info(){{#appName}} | ||
.title("{{appName}}"){{/appName}} | ||
.description("{{{appDescription}}}"){{#termsOfService}} | ||
.termsOfService("{{termsOfService}}"){{/termsOfService}}{{#openAPI}}{{#info}}{{#contact}} | ||
.contact( | ||
Contact(){{#infoName}} | ||
.name("{{infoName}}"){{/infoName}}{{#infoUrl}} | ||
.url("{{infoUrl}}"){{/infoUrl}}{{#infoEmail}} | ||
.email("{{infoEmail}}"){{/infoEmail}} | ||
){{/contact}}{{#license}} | ||
.license( | ||
License() | ||
{{#licenseInfo}}.name("{{licenseInfo}}") | ||
{{/licenseInfo}}{{#licenseUrl}}.url("{{licenseUrl}}") | ||
{{/licenseUrl}} | ||
){{/license}}{{/info}}{{/openAPI}} | ||
.version("{{appVersion}}") | ||
){{#hasAuthMethods}} | ||
.components( | ||
Components(){{#authMethods}} | ||
.addSecuritySchemes("{{name}}", SecurityScheme(){{#isBasic}} | ||
.type(SecurityScheme.Type.HTTP) | ||
.scheme("{{scheme}}"){{#bearerFormat}} | ||
.bearerFormat("{{bearerFormat}}"){{/bearerFormat}}{{/isBasic}}{{#isApiKey}} | ||
.type(SecurityScheme.Type.APIKEY){{#isKeyInHeader}} | ||
.`in`(SecurityScheme.In.HEADER){{/isKeyInHeader}}{{#isKeyInQuery}} | ||
.`in`(SecurityScheme.In.QUERY){{/isKeyInQuery}}{{#isKeyInCookie}} | ||
.`in`(SecurityScheme.In.COOKIE){{/isKeyInCookie}} | ||
.name("{{keyParamName}}"){{/isApiKey}}{{#isOAuth}} | ||
.type(SecurityScheme.Type.OAUTH2){{/isOAuth}} | ||
){{/authMethods}} | ||
){{/hasAuthMethods}} | ||
} | ||
} |
File renamed without changes.
33 changes: 0 additions & 33 deletions
33
...re/kotlin-server/jaxrs-spec/src/main/kotlin/org/openapitools/server/models/ApiResponse.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/SpringDocConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.openapitools | ||
|
||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
import io.swagger.v3.oas.models.OpenAPI | ||
import io.swagger.v3.oas.models.info.Info | ||
import io.swagger.v3.oas.models.info.Contact | ||
import io.swagger.v3.oas.models.info.License | ||
import io.swagger.v3.oas.models.Components | ||
import io.swagger.v3.oas.models.security.SecurityScheme | ||
|
||
@jakarta.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"]) | ||
@Configuration | ||
class SpringDocConfiguration { | ||
|
||
@Bean | ||
fun apiInfo(): OpenAPI { | ||
return OpenAPI() | ||
.info( | ||
Info() | ||
.title("OpenAPI Petstore") | ||
.description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.") | ||
.license( | ||
License() | ||
.name("Apache-2.0") | ||
.url("https://www.apache.org/licenses/LICENSE-2.0.html") | ||
) | ||
.version("1.0.0") | ||
) | ||
.components( | ||
Components() | ||
.addSecuritySchemes("api_key", SecurityScheme() | ||
.type(SecurityScheme.Type.APIKEY) | ||
.`in`(SecurityScheme.In.HEADER) | ||
.name("api_key") | ||
) | ||
.addSecuritySchemes("petstore_auth", SecurityScheme() | ||
.type(SecurityScheme.Type.OAUTH2) | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/SpringDocConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.openapitools | ||
|
||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
import io.swagger.v3.oas.models.OpenAPI | ||
import io.swagger.v3.oas.models.info.Info | ||
import io.swagger.v3.oas.models.info.Contact | ||
import io.swagger.v3.oas.models.info.License | ||
import io.swagger.v3.oas.models.Components | ||
import io.swagger.v3.oas.models.security.SecurityScheme | ||
|
||
@jakarta.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"]) | ||
@Configuration | ||
class SpringDocConfiguration { | ||
|
||
@Bean | ||
fun apiInfo(): OpenAPI { | ||
return OpenAPI() | ||
.info( | ||
Info() | ||
.title("OpenAPI Petstore") | ||
.description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.") | ||
.license( | ||
License() | ||
.name("Apache-2.0") | ||
.url("https://www.apache.org/licenses/LICENSE-2.0.html") | ||
) | ||
.version("1.0.0") | ||
) | ||
.components( | ||
Components() | ||
.addSecuritySchemes("api_key", SecurityScheme() | ||
.type(SecurityScheme.Type.APIKEY) | ||
.`in`(SecurityScheme.In.HEADER) | ||
.name("api_key") | ||
) | ||
.addSecuritySchemes("petstore_auth", SecurityScheme() | ||
.type(SecurityScheme.Type.OAUTH2) | ||
) | ||
) | ||
} | ||
} |