Skip to content

Commit

Permalink
Reference code API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
p1c2u committed Feb 12, 2024
1 parent 9762b79 commit 5cb0824
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 3 deletions.
9 changes: 9 additions & 0 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
API Reference
=============

Documentation with information of functions, classes or methods and all other parts of the OpenAPI-core public API.

.. toctree::
:maxdepth: 1

openapi
5 changes: 5 additions & 0 deletions docs/api/openapi.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
`OpenAPI` class
===============

.. autoclass:: openapi_core.OpenAPI
:members:
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"sphinx.ext.intersphinx",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
"sphinx_autodoc_typehints",
"sphinx_immaterial",
]

Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ openapi-core
customizations/index
security
extensions
api/index
contributing

Openapi-core is a Python library that adds client-side and server-side support
Expand Down
16 changes: 15 additions & 1 deletion openapi_core/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,17 @@


class OpenAPI:
"""OpenAPI class."""
"""`OpenAPI` application class, the main entrypoint class for OpenAPI-core.
Read more information, in the
[OpenAPI-core docs for First Steps](https://openapi-core.readthedocs.io/#first-steps).
Import :class:`OpenAPI` class from the main `openapi_core` module::
from openapi_core import OpenAPI
app = OpenAPI(spec)
"""

def __init__(
self,
Expand All @@ -90,27 +100,31 @@ def __init__(
def from_dict(
cls, data: Schema, config: Optional[Config] = None
) -> "OpenAPI":
"""Creates :class:`OpenAPI` class instance from a dictionary."""
sp = SchemaPath.from_dict(data)
return cls(sp, config=config)

@classmethod
def from_path(
cls, path: Path, config: Optional[Config] = None
) -> "OpenAPI":
"""Creates :class:`OpenAPI` class instance from a path object."""
sp = SchemaPath.from_path(path)
return cls(sp, config=config)

@classmethod
def from_file_path(
cls, file_path: str, config: Optional[Config] = None
) -> "OpenAPI":
"""Creates :class:`OpenAPI` class instance from a file path string."""
sp = SchemaPath.from_file_path(file_path)
return cls(sp, config=config)

@classmethod
def from_file(
cls, fileobj: SupportsRead, config: Optional[Config] = None
) -> "OpenAPI":
"""Creates :class:`OpenAPI` class instance from a file object."""
sp = SchemaPath.from_file(fileobj)
return cls(sp, config=config)

Expand Down
23 changes: 21 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pyflakes = "^3.1.0"
[tool.poetry.group.docs.dependencies]
sphinx = ">=5.3,<8.0"
sphinx-immaterial = "^0.11.0"
sphinx-autodoc-typehints = "^2.0.0"

[tool.pytest.ini_options]
addopts = """
Expand Down

0 comments on commit 5cb0824

Please sign in to comment.