Skip to content

Commit

Permalink
Add config doc (#191)
Browse files Browse the repository at this point in the history
* fix typo

* add models to doc

* add config docs

* change mode class doc to attribute doc
  • Loading branch information
kemingy committed Jan 6, 2022
1 parent 9b66516 commit a2125cc
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
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

0 comments on commit a2125cc

Please sign in to comment.