Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config doc #191

Merged
merged 4 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Spectree
# SpecTree


[![GitHub Actions](https://github.com/0b01001001/spectree/workflows/Python%20package/badge.svg)](https://github.com/0b01001001/spectree/actions)
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ cases, in Starlette are lower cases.
config
response
plugins
models
utils


Expand Down
5 changes: 5 additions & 0 deletions docs/source/models.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Models
==========

.. automodule:: spectree.models
:members:
39 changes: 36 additions & 3 deletions spectree/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,73 @@


class ModeEnum(str, Enum):
"""the mode of the SpecTree validator"""

#: includes undecorated routes and routes decorated by this instance
normal = "normal"
#: only includes routes decorated by this instance
strict = "strict"
#: includes all the routes
greedy = "greedy"


class Contact(BaseModel):
"""contact information"""

#: name of the contact
name: str
url: AnyUrl = ""
email: EmailStr = ""
#: contact url
url: AnyUrl = None
#: contact email address
email: EmailStr = None


class License(BaseModel):
"""license information"""

#: name of the license
name: str
url: AnyUrl = ""
#: license url
url: AnyUrl = None


class Configuration(BaseSettings):
# OpenAPI configurations
#: title of the service
title: str = "Service API Document"
#: service OpenAPI document description
description: str = None
#: service version
version: str = "0.1.0"
#: terms of service url
terms_of_service: AnyUrl = None
#: author contact information
contact: Contact = None
#: license information
license: License = None

# SpecTree configurations
#: OpenAPI doc route path prefix (i.e. /apidoc/)
path: str = "apidoc"
#: OpenAPI file route path suffix (i.e. /apidoc/openapi.json)
filename: str = "openapi.json"
#: OpenAPI version (doesn't affect anything)
openapi_version: str = "3.0.3"
#: the mode of the SpecTree validator :class:`ModeEnum`
mode: ModeEnum = ModeEnum.normal
#: 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
page_templates = DEFAULT_PAGE_TEMPLATES
#: opt-in type annotation feature, see the README examples
annotations = False
#: servers section of OAS :py:class:`spectree.models.Server`
servers: Optional[List[Server]] = []
#: OpenAPI `securitySchemes` :py:class:`spectree.models.SecurityScheme`
security_schemes: Optional[List[SecurityScheme]] = None
#: OpenAPI `security` JSON at the global level
security: Dict = {}

class Config:
Expand Down