from dataclasses import dataclass

from ._ApiKeyInEnum import ApiKeyInEnum
from ._SecuritySchemaModel import SecuritySchemaModel
from ._SecuritySchemeTypeEnum import SecuritySchemeTypeEnum


@dataclass
class ApiKeySecuritySchemaModel(SecuritySchemaModel):
    type: str = SecuritySchemeTypeEnum.api_key
    in_location: ApiKeyInEnum = ApiKeyInEnum.header
    name: str = None

    def get_field_key(self, field_name: str) -> str:
        if field_name == "in_location":
            return "in"
        return super().get_field_key(field_name)