Source code for apigraph.conf.types
from enum import Enum
from typing import Optional, no_type_check
from pydantic import BaseSettings
[docs]class CoerceEnumSettings(BaseSettings):
"""
Allow to set value via Enum member name rather than enum instance to fields
having an Enum type, in conjunction with Config.validate_assignment = True
"""
@no_type_check
def __setattr__(self, name, value):
field = self.__fields__[name]
if issubclass(field.type_, Enum) and not isinstance(value, Enum):
value = field.type_[value]
return super().__setattr__(name, value)
[docs]class Settings(CoerceEnumSettings):
[docs] class Config:
validate_assignment = True
env_prefix = "APIGRAPH_"
CACHE_DIR: Optional[str] = ".apigraph" # uses tmp if None, relative to exec dir
CACHE_EXPIRE: Optional[float] = None
BACKLINKS_ATTR: str = "x-apigraph-backlinks"
LINK_CHAIN_ID_ATTR: str = "x-apigraph-chainId"
LINK_REQUEST_BODY_PARAMS_ATTR: str = "x-apigraph-requestBodyParameters"