All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.lancom.openapi.entity.HTTPSecurityScheme.kt Maven / Gradle / Ivy

Go to download

This open-source project provides an OpenAPI 3.0 Parser implemented in Kotlin, utilizing immutable data classes

There is a newer version: 2.1.1
Show newest version
/*****************************************************************************
**   C A U T I O N                                                          **
**   This file is auto-generated!                                           **
**   If you want to make changes, please see the README.md file.            **
**   Please do not edit this file directly!                                 **
*****************************************************************************/
package de.lancom.openapi.entity

import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import de.lancom.openapi.field.Field
import de.lancom.openapi.jackson.EntityDeserializer
import de.lancom.openapi.jackson.EntitySerializer
import de.lancom.openapi.jackson.ReferenceParser
import de.lancom.openapi.jackson.Wrapper
import de.lancom.openapi.tools.toYamlString

// hint:9A1BF04C
@Suppress("PropertyName")
@JsonSerialize(using = HTTPSecurityScheme.Companion.Serializer::class)
@JsonDeserialize(using = HTTPSecurityScheme.Companion.Deserializer::class)
data class HTTPSecurityScheme(
    val _scheme: Field = Field.unset(),
    val _bearerFormat: Field = Field.unset(),
    val _description: Field = Field.unset(),
    val _extensions: Field> = Field.unset(),
) : SecurityScheme {

    ///////////////////////
    //
    // scheme
    //
    ///////////////////////

    // hint:3A7F9B2E
    val scheme: String?
        get() = _scheme.orNull

    // hint:F0C48D71
    fun setSchemeField(scheme: Field): HTTPSecurityScheme {
        return copy(_scheme = scheme)
    }

    // hint:8E56A4D9
    fun updateSchemeField(updater: (Field) -> Field): HTTPSecurityScheme {
        return setSchemeField(updater(_scheme))
    }

    // hint:B1D730FC
    fun updateScheme(updater: (String?) -> String?): HTTPSecurityScheme {
        return updateSchemeField { field ->
            field.flatMap { value ->
                Field(updater(value))
            }
        }
    }

    // hint:6542E98A
    fun mergeSchemeField(schemeFieldToMerge: Field): HTTPSecurityScheme {
        return mergeScheme(schemeFieldToMerge.orNull)
    }

    // hint:A8BC6F23
    fun mergeScheme(schemeToMerge: String?): HTTPSecurityScheme {
        return if (schemeToMerge == null) {
            this
        } else {
            val oldScheme = _scheme.orNull
            if (oldScheme == null) {
                setSchemeField(Field(schemeToMerge))
            } else {
                // hint:2F684DAC
                setScheme(schemeToMerge)
            }
        }
    }

    // hint:87B3E19C
    fun setScheme(scheme: String?): HTTPSecurityScheme {
        return setSchemeField(Field(scheme))
    }

    // hint:D465F782
    fun unsetScheme(): HTTPSecurityScheme {
        return setSchemeField(Field.unset())
    }

    // hint:47C9A0F6
    fun addScheme(scheme: String): HTTPSecurityScheme {
        if (this.scheme != null) {
            throw IllegalStateException("Field scheme of Entity HTTPSecurityScheme is already set to '${this.scheme}', refused to add new value '$scheme'")
        }
        return setScheme(scheme)
    }

    ///////////////////////
    //
    // bearerFormat
    //
    ///////////////////////

    // hint:3A7F9B2E
    val bearerFormat: String?
        get() = _bearerFormat.orNull

    // hint:F0C48D71
    fun setBearerFormatField(bearerFormat: Field): HTTPSecurityScheme {
        return copy(_bearerFormat = bearerFormat)
    }

    // hint:8E56A4D9
    fun updateBearerFormatField(updater: (Field) -> Field): HTTPSecurityScheme {
        return setBearerFormatField(updater(_bearerFormat))
    }

    // hint:B1D730FC
    fun updateBearerFormat(updater: (String?) -> String?): HTTPSecurityScheme {
        return updateBearerFormatField { field ->
            field.flatMap { value ->
                Field(updater(value))
            }
        }
    }

    // hint:6542E98A
    fun mergeBearerFormatField(bearerFormatFieldToMerge: Field): HTTPSecurityScheme {
        return mergeBearerFormat(bearerFormatFieldToMerge.orNull)
    }

    // hint:A8BC6F23
    fun mergeBearerFormat(bearerFormatToMerge: String?): HTTPSecurityScheme {
        return if (bearerFormatToMerge == null) {
            this
        } else {
            val oldBearerFormat = _bearerFormat.orNull
            if (oldBearerFormat == null) {
                setBearerFormatField(Field(bearerFormatToMerge))
            } else {
                // hint:2F684DAC
                setBearerFormat(bearerFormatToMerge)
            }
        }
    }

    // hint:87B3E19C
    fun setBearerFormat(bearerFormat: String?): HTTPSecurityScheme {
        return setBearerFormatField(Field(bearerFormat))
    }

    // hint:D465F782
    fun unsetBearerFormat(): HTTPSecurityScheme {
        return setBearerFormatField(Field.unset())
    }

    // hint:47C9A0F6
    fun addBearerFormat(bearerFormat: String): HTTPSecurityScheme {
        if (this.bearerFormat != null) {
            throw IllegalStateException("Field bearerFormat of Entity HTTPSecurityScheme is already set to '${this.bearerFormat}', refused to add new value '$bearerFormat'")
        }
        return setBearerFormat(bearerFormat)
    }

    ///////////////////////
    //
    // description
    //
    ///////////////////////

    // hint:3A7F9B2E
    val description: String?
        get() = _description.orNull

    // hint:F0C48D71
    fun setDescriptionField(description: Field): HTTPSecurityScheme {
        return copy(_description = description)
    }

    // hint:8E56A4D9
    fun updateDescriptionField(updater: (Field) -> Field): HTTPSecurityScheme {
        return setDescriptionField(updater(_description))
    }

    // hint:B1D730FC
    fun updateDescription(updater: (String?) -> String?): HTTPSecurityScheme {
        return updateDescriptionField { field ->
            field.flatMap { value ->
                Field(updater(value))
            }
        }
    }

    // hint:6542E98A
    fun mergeDescriptionField(descriptionFieldToMerge: Field): HTTPSecurityScheme {
        return mergeDescription(descriptionFieldToMerge.orNull)
    }

    // hint:A8BC6F23
    fun mergeDescription(descriptionToMerge: String?): HTTPSecurityScheme {
        return if (descriptionToMerge == null) {
            this
        } else {
            val oldDescription = _description.orNull
            if (oldDescription == null) {
                setDescriptionField(Field(descriptionToMerge))
            } else {
                // hint:2F684DAC
                setDescription(descriptionToMerge)
            }
        }
    }

    // hint:87B3E19C
    fun setDescription(description: String?): HTTPSecurityScheme {
        return setDescriptionField(Field(description))
    }

    // hint:D465F782
    fun unsetDescription(): HTTPSecurityScheme {
        return setDescriptionField(Field.unset())
    }

    // hint:47C9A0F6
    fun addDescription(description: String): HTTPSecurityScheme {
        if (this.description != null) {
            throw IllegalStateException("Field description of Entity HTTPSecurityScheme is already set to '${this.description}', refused to add new value '$description'")
        }
        return setDescription(description)
    }

    // hint:C89A3E1F
    override val type: SecuritySchemeType = SecuritySchemeType.http

    ///////////////////////
    //
    // extensions
    //
    ///////////////////////

    // hint:3A7F9B2E
    val extensions: Map
        get() = _extensions.orNull ?: emptyMap()

    // hint:F0C48D71
    fun setExtensionsField(extensions: Field>): HTTPSecurityScheme {
        return copy(_extensions = extensions)
    }

    // hint:8E56A4D9
    fun updateExtensionsField(updater: (Field>) -> Field>): HTTPSecurityScheme {
        return setExtensionsField(updater(_extensions))
    }

    // hint:B1D730FC
    fun updateExtensions(updater: (Map) -> Map): HTTPSecurityScheme {
        return updateExtensionsField { field ->
            field.flatMap { value ->
                Field(updater(value))
            }
        }
    }

    // hint:6542E98A
    fun mergeExtensionsField(extensionsFieldToMerge: Field>): HTTPSecurityScheme {
        return mergeExtensions(extensionsFieldToMerge.orNull)
    }

    // hint:A8BC6F23
    fun mergeExtensions(extensionsToMerge: Map?): HTTPSecurityScheme {
        return if (extensionsToMerge == null) {
            this
        } else {
            val oldExtensions = _extensions.orNull
            if (oldExtensions == null) {
                setExtensionsField(Field(extensionsToMerge))
            } else {
                // hint:70A3D8B6
                setExtensions(de.lancom.openapi.tools.mergeMap(oldExtensions, extensionsToMerge))
            }
        }
    }

    // hint:87B3E19C
    fun setExtensions(extensions: Map): HTTPSecurityScheme {
        return setExtensionsField(Field(extensions))
    }

    // hint:D465F782
    fun unsetExtensions(): HTTPSecurityScheme {
        return setExtensionsField(Field.unset())
    }

    // hint:5C81D396
    fun addExtensions(extensions: Map): HTTPSecurityScheme {
        return mergeExtensions(extensions)
    }

    // hint:1A6B37F8
    fun addExtensions(vararg extensions: Pair): HTTPSecurityScheme {
        return addExtensions(extensions.toMap())
    }

    // hint:9D0E4CA5
    fun addExtension(key: String, value: Extension?): HTTPSecurityScheme {
        return addExtensions(key to value)
    }

    // hint:B8F25E73
    fun addExtension(pair: Pair): HTTPSecurityScheme {
        return addExtensions(mapOf(pair))
    }

    // hint:6A81E3FD
    override val entityDescriptor: EntityDescriptor by lazy {
        EntityDescriptor(
            entity = this,
            jsonNode = null,
            map = mapOf(
                "scheme" to _scheme,
                "bearerFormat" to _bearerFormat,
                "description" to _description,
                "type" to Field(type),
            ),
            flatMap = listOf(
                _extensions,
            ),
            flatten = listOf(
            ),
        )
    }

    override fun toString(): String {
        return this.toYamlString()
    }

    // hint:A0E5F382
    override fun mergeEntity(other: Entity?): HTTPSecurityScheme {
        return when (other) {
            null ->
                this

            is HTTPSecurityScheme ->
                merge(other)

            else ->
                TODO()
        }
    }

    // hint:716BFD54
    fun merge(other: SecurityScheme?): HTTPSecurityScheme {
        if (other == null) return this
        if (other !is HTTPSecurityScheme) TODO()
        return this
            .mergeSchemeField(other._scheme)
            .mergeBearerFormatField(other._bearerFormat)
            .mergeDescriptionField(other._description)
            .mergeExtensionsField(other._extensions)
    }

    companion object : ReferenceParser {

        class Serializer : EntitySerializer(SecurityScheme::class.java, HTTPSecurityScheme)
        class Deserializer : EntityDeserializer(SecurityScheme::class.java, HTTPSecurityScheme)

        // hint:5F72B6D8
        override fun parseWrapper(wrapper: Wrapper): SecurityScheme {
            return de.lancom.openapi.jackson.extensionParser(wrapper, ::parseWrapperWithExtensions)
        }

        // hint:2C0E94A7
        fun parseWrapperWithExtensions(wrapper: Wrapper, extensions: Field>): HTTPSecurityScheme {
            return HTTPSecurityScheme(
                _scheme = wrapper["scheme"].getNullOrElse {
                    getSingle {
                        getSingle {
                            getString()
                        }
                    }
                },
                _bearerFormat = wrapper["bearerFormat"].getNullOrElse {
                    getSingle {
                        getSingle {
                            getString()
                        }
                    }
                },
                _description = wrapper["description"].getNullOrElse {
                    getSingle {
                        getSingle {
                            getString()
                        }
                    }
                },
                _extensions = extensions,
            )
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy