Config

class spectree.config.Configuration[source]

Global configuration.

__init__(**kwargs: Any) None[source]
additional_query_string_params: Dict[str, str]

OAuth2 additional query string params

annotations: bool = True

opt-in type annotation feature, see the README examples

app_name: str = 'spectree_app'

OAuth2 app name

client_id: str = ''

OAuth2 client id

client_secret: str = ''

OAuth2 client secret

contact: Contact | None = None

author contact information

description: str | None = None

service OpenAPI document description

error_type

alias of ConfigurationError

filename: str = 'openapi.json'

OpenAPI file route path suffix (i.e. /apidoc/openapi.json)

license: License | None = None

license information

mode: ModeEnum = 'normal'

the mode of the SpecTree validator ModeEnum

openapi_version: str = '3.1.0'

OpenAPI version (doesn’t affect anything)

page_templates: Dict[str, str]

A dictionary of documentation page templates. The key is the name of the template, that is also used in the URL path, while the value is used to render the documentation page content. (Each page template should contain a {spec_url} placeholder, that’ll be replaced by the actual OpenAPI spec URL in the rendered documentation page

path: str = 'apidoc'

OpenAPI doc route path prefix (i.e. /apidoc/)

realm: str = ''

OAuth2 realm

scope_separator: str = ' '

OAuth2 scope separator

scopes: List[str]

OAuth2 scopes

security: Dict[str, List[str]] | List[Dict[str, List[str]]]

OpenAPI security JSON at the global level

security_schemes: List[SecurityScheme] | None = None

OpenAPI securitySchemes spectree.models.SecurityScheme

servers: List[Server]

servers section of OAS spectree.models.Server

swagger_oauth2_config() Dict[str, Any][source]

return the swagger UI OAuth2 configs

ref: https://swagger.io/docs/open-source-tools/swagger-ui/usage/oauth2/

terms_of_service: str | None = None

terms of service url

title: str = 'Service API Document'

title of the service

use_basic_authentication_with_access_code_grant: bool = False

OAuth2 use basic authentication with access code grant

use_pkce_with_authorization_code_grant: bool = False

OAuth2 use PKCE with authorization code grant

version: str = '0.1.0'

service version

exception spectree.config.ConfigurationError[source]

Configuration validation error.

class spectree.config.Contact[source]

contact information

__init__(name: str, url: str | None = None, email: str | None = None) None
email: str | None = None

contact email address

error_type

alias of ConfigurationError

name: str

name of the contact

url: str | None = None

contact url

class spectree.config.License[source]

license information

__init__(name: str, url: str | None = None) None
error_type

alias of ConfigurationError

name: str

name of the license

url: str | None = None

license url

class spectree.config.ModeEnum[source]

the mode of the SpecTree validator

__new__(value)
greedy = 'greedy'

includes all the routes

normal = 'normal'

includes undecorated routes and routes decorated by this instance

strict = 'strict'

only includes routes decorated by this instance