security schema component
This commit is contained in:
@ -4,11 +4,11 @@ data class OpenApiSpec(
|
||||
val openapi: String = "3.0.3",
|
||||
val info: OpenApiSpecInfo? = null,
|
||||
// TODO Needs to default to server object with url of `/`
|
||||
val servers: List<OpenApiSpecServer> = emptyList(),
|
||||
val paths: Map<String, OpenApiSpecPathItem> = emptyMap(),
|
||||
val servers: List<OpenApiSpecServer>? = null,
|
||||
val paths: Map<String, OpenApiSpecPathItem>? = null,
|
||||
val components: OpenApiSpecComponents? = null,
|
||||
// todo needs to reference objects in the components -> security scheme 🤔
|
||||
val security: Map<String, String> = emptyMap(),
|
||||
val tags: List<OpenApiSpecTag> = emptyList(),
|
||||
val security: List<Map<String, List<String>>>? = null,
|
||||
val tags: List<OpenApiSpecTag>? = null,
|
||||
val externalDocs: OpenApiSpecExternalDocumentation? = null
|
||||
)
|
||||
|
@ -2,5 +2,5 @@ package org.leafygreens.kompendium.models
|
||||
|
||||
// TODO I *think* the only thing I need here is the security https://swagger.io/specification/#components-object
|
||||
data class OpenApiSpecComponents(
|
||||
val securitySchemes: Map<String, OpenApiSpecReferencable>
|
||||
val securitySchemes: Map<String, OpenApiSpecSchema>
|
||||
)
|
||||
|
@ -3,8 +3,8 @@ package org.leafygreens.kompendium.models
|
||||
import java.net.URI
|
||||
|
||||
data class OpenApiSpecOAuthFlow(
|
||||
val authorizationUrl: URI,
|
||||
val tokenUrl: URI,
|
||||
val refreshUrl: URI,
|
||||
val scopes: Map<String, String>
|
||||
val authorizationUrl: URI? = null,
|
||||
val tokenUrl: URI? = null,
|
||||
val refreshUrl: URI? = null,
|
||||
val scopes: Map<String, String>? = null
|
||||
)
|
||||
|
@ -19,3 +19,13 @@ data class OpenApiSpecSchemaString(
|
||||
data class OpenApiSpecSchemaRef(
|
||||
val `$ref`: String
|
||||
) : OpenApiSpecSchema()
|
||||
|
||||
data class OpenApiSpecSchemaSecurity(
|
||||
val type: String? = null, // TODO Enum? "apiKey", "http", "oauth2", "openIdConnect"
|
||||
val name: String? = null,
|
||||
val `in`: String? = null,
|
||||
val scheme: String? = null,
|
||||
val flows: OpenApiSpecOAuthFlows? = null,
|
||||
val bearerFormat: String? = null,
|
||||
val description: String? = null,
|
||||
) : OpenApiSpecSchema()
|
||||
|
@ -1,12 +0,0 @@
|
||||
package org.leafygreens.kompendium.models
|
||||
|
||||
data class OpenApiSpecSecuritySchema(
|
||||
val type: String, // TODO Enum? "apiKey", "http", "oauth2", "openIdConnect"
|
||||
val name: String,
|
||||
val `in`: String,
|
||||
val scheme: String,
|
||||
val flows: OpenApiSpecOAuthFlows,
|
||||
val bearerFormat: String?,
|
||||
val description: String?,
|
||||
)
|
||||
|
@ -3,20 +3,23 @@ package org.leafygreens.kompendium.util
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
import org.leafygreens.kompendium.models.OpenApiSpec
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecComponents
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecExternalDocumentation
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecInfo
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecInfoContact
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecInfoLicense
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecMediaType
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecOAuthFlow
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecOAuthFlows
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecParameter
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecSchemaArray
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecSchemaString
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecPathItem
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecPathItemOperation
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecReferenceObject
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecRequest
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecResponse
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecSchemaArray
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecSchemaRef
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecSchemaSecurity
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecSchemaString
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecServer
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecTag
|
||||
|
||||
@ -192,6 +195,27 @@ object TestData {
|
||||
))
|
||||
)
|
||||
)
|
||||
),
|
||||
components = OpenApiSpecComponents(
|
||||
securitySchemes = mapOf(
|
||||
"petstore_auth" to OpenApiSpecSchemaSecurity(
|
||||
type = "oauth2",
|
||||
flows = OpenApiSpecOAuthFlows(
|
||||
implicit = OpenApiSpecOAuthFlow(
|
||||
authorizationUrl = URI("http://petstore.swagger.io/oauth/dialog"),
|
||||
scopes = mapOf(
|
||||
"write:pets" to "modify pets in your account",
|
||||
"read:pets" to "read your pets"
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
"api_key" to OpenApiSpecSchemaSecurity(
|
||||
type = "apiKey",
|
||||
name = "api_key",
|
||||
`in` = "header"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -152,7 +152,27 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"security" : { },
|
||||
"components" : {
|
||||
"securitySchemes" : {
|
||||
"petstore_auth" : {
|
||||
"type" : "oauth2",
|
||||
"flows" : {
|
||||
"implicit" : {
|
||||
"authorizationUrl" : "http://petstore.swagger.io/oauth/dialog",
|
||||
"scopes" : {
|
||||
"write:pets" : "modify pets in your account",
|
||||
"read:pets" : "read your pets"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"api_key" : {
|
||||
"type" : "apiKey",
|
||||
"name" : "api_key",
|
||||
"in" : "header"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "pet",
|
||||
"description" : "Everything about your Pets",
|
||||
|
Reference in New Issue
Block a user