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

Update docs #155

Merged
merged 2 commits into from
Aug 31, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
</a>
</p>

> This branch is in development preview state.

**Flask OpenAPI3** is a web API framework based on **Flask**. It uses **Pydantic** to verify data and automatic
generation of interaction documentation.

Expand Down
6 changes: 0 additions & 6 deletions docs/Quickstart.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ if __name__ == '__main__':

## 嵌套 APIBlueprint

*v2.0.0 新增*

允许一个 **API Blueprint** 被另一个 **API Blueprint** 注册。

更多信息请查看 [Flask Nesting Blueprints](https://flask.palletsprojects.com/en/latest/blueprints/#nesting-blueprints)。
Expand Down Expand Up @@ -128,8 +126,6 @@ if __name__ == '__main__':

## APIView

*v2.2.0 新增*

[基于类的 API 视图](./Reference/APIView.md), 点击[这里](https://github.com/luolingchun/flask-openapi3/blob/APIView/examples/api_view_demo.py) 查看完整示例:

```python
Expand All @@ -150,8 +146,6 @@ class BookListAPIView:

## 异步 API

*v2.2.2 新增*

在定义函数时使用 `async`。 更多信息参考 [Using async and await — Flask Documentation](https://flask.palletsprojects.com/en/latest/async-await/)。

!!! info
Expand Down
72 changes: 68 additions & 4 deletions docs/Usage/Configuration.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Flask supports many [configurations](https://flask.palletsprojects.com/en/latest/config/), and there are also some
configurations in this library that can be used.

## SWAGGER_HTML_STRING

You can customize the custom behavior of this template.

[The default `SWAGGER_HTML_STRING` is here](https://github.com/luolingchun/flask-openapi3-plugins/blob/master/flask-openapi3-swagger/flask_openapi3_swagger/templates/__init__.py).

## SWAGGER_CONFIG

You can change the default behavior of the Swagger UI.
Expand All @@ -16,8 +22,7 @@ app.config["SWAGGER_CONFIG"] = {
}
```

Here are more configuration options for Swagger UI, which you can
find [here](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md).
[More configuration options for Swagger UI](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md).

## OAUTH_CONFIG

Expand All @@ -31,5 +36,64 @@ app = OpenAPI(__name__)
app.config["OAUTH_CONFIG"] = {"clientId": "xxx", "clientSecret": "xxx"}
```

Here are more configuration options for OAuth 2.0 configuration, which you can
find [here](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/oauth2.md).
[More configuration options for Swagger UI](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/oauth2.md).

## SCALAR_HTML_STRING

You can customize the custom behavior of this template.

[The default `SCALAR_HTML_STRING` is here](https://github.com/luolingchun/flask-openapi3-plugins/blob/master/flask-openapi3-scalar/flask_openapi3_scalar/templates/__init__.py).

## SCALAR_CONFIG

You can change the default behavior of the Scalar UI.

[More configuration options for Swagger UI](https://github.com/scalar/scalar/blob/main/documentation/configuration.md).

## REDOC_HTML_STRING
You can customize the custom behavior of this template.

[The default `REDOC_HTML_STRING` is here](https://github.com/luolingchun/flask-openapi3-plugins/blob/master/flask-openapi3-redoc/flask_openapi3_redoc/templates/__init__.py).

## REDOC_CONFIG

You can change the default behavior of the Redoc UI.

[More configuration options for Redoc UI](https://github.com/Redocly/redoc/blob/main/docs/config.md).

## RAPIDOC_HTML_STRING

You can customize the custom behavior of this template.

[The default `RAPIDOC_HTML_STRING` is here](https://github.com/luolingchun/flask-openapi3-plugins/blob/master/flask-openapi3-rapidoc/flask_openapi3_rapidoc/templates/__init__.py).

## RAPIDOC_CONFIG

You can change the default behavior of the Rapidoc UI.

[More configuration options for Rapidoc UI](https://rapidocweb.com/examples.html).

## RAPIPDF_HTML_STRING

You can customize the custom behavior of this template.

[The default `RAPIPDF_HTML_STRING` is here](https://github.com/luolingchun/flask-openapi3-plugins/blob/master/flask-openapi3-rapipdf/flask_openapi3_rapipdf/templates/__init__.py).

## RAPIPDF_CONFIG

You can change the default behavior of the Rapipdf UI.

[More configuration options for Rapipdf UI](https://mrin9.github.io/RapiPdf/).

## ELEMENTS_HTML_STRING

You can customize the custom behavior of this template.

[The default `ELEMENTS_HTML_STRING` is here](https://github.com/luolingchun/flask-openapi3-plugins/blob/master/flask-openapi3-elements/flask_openapi3_elements/templates/__init__.py).


## ELEMENTS_CONFIG

You can change the default behavior of the Elements UI.

[More configuration options for Rapipdf UI](https://github.com/stoplightio/elements/blob/main/docs/getting-started/elements/elements-options.md).
148 changes: 2 additions & 146 deletions docs/Usage/Specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ Usage: flask openapi [OPTIONS]

Options:
-o, --output PATH The output file path.
-f, --format [json|yaml|markdown]
-f, --format [json|yaml]
The output file format.
-i, --indent INTEGER The indentation for JSON dumps.
-a, --ensure_ascii Ensure ASCII characters or not. Defaults to
False.
--help Show this message and exit.

```
Expand Down Expand Up @@ -70,7 +68,7 @@ if __name__ == '__main__':

run it, and go to http://127.0.0.1:5000/openapi, you will see the documentation.

![openapi](../images/openapi.png)
![openapi](../images/openapi-all.png)
![image-20210525160157057](../assets/image-20210525160157057.png)

## security_schemes
Expand Down Expand Up @@ -139,67 +137,6 @@ result:

![image-20210525165350520](../assets/image-20210525165350520.png)


## oauth_config

!!! Deprecated-Warning warning

The `oauth_config` is deprecated in v4.x, use `app.config['OAUTH_CONFIG']` instead.

```python
from flask_openapi3 import OpenAPI

app = OpenAPI(__name__)

app.config["OAUTH_CONFIG"] = {"clientId": "xxx", "clientSecret": "xxx"}
```

You can pass `oauth_config` when initializing `OpenAPI`:

```python
from flask_openapi3 import OpenAPI, OAuthConfig
from flask_openapi3 import Info

info = Info(title='oauth API', version='1.0.0')

oauth_config = OAuthConfig(
clientId="xxx",
clientSecret="xxx"
)

oauth2 = {
"type": "oauth2",
"flows": {
"implicit": {
"authorizationUrl": "https://example.com/api/oauth/dialog",
"scopes": {
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
}
}
}
}

security_schemes = {"oauth2": oauth2}

app = OpenAPI(__name__, info=info, oauth_config=oauth_config, security_schemes=security_schemes)

security = [
{"oauth2": ["write:pets", "read:pets"]}
]


@app.get("/", security=security)
def oauth():
return "oauth"


if __name__ == '__main__':
app.run(debug=True)
```

Here's more information about [OAuth 2.0 configuration](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/oauth2.md)

## responses

You can add `responses` for each API under the `app` wrapper.
Expand Down Expand Up @@ -267,87 +204,6 @@ def get_book():
...
```

## doc_expansion

!!! Deprecated-Warning warning

The `doc_expansion` is deprecated in v4.x, use `app.config['SWAGGER_CONFIG']` instead.

```python
from flask_openapi3 import OpenAPI

app = OpenAPI(__name__)

app.config["SWAGGER_CONFIG"] = {
"docExpansion": "none",
"validatorUrl": "https://www.b.com"
}
```

Just for Swagger UI.

String=["list", "full", "none"].

Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), full' (expands the tags and operations) or 'none' (expands nothing).

More information to see [Configuration](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md).

```python
app = OpenAPI(__name__, info=info, doc_expansion='full')
```

## swagger_config

!!! Deprecated-Warning warning

The `doc_expansion` is deprecated in v4.x, use `app.config['SWAGGER_CONFIG']` instead.

```python
from flask_openapi3 import OpenAPI

app = OpenAPI(__name__)

app.config["SWAGGER_CONFIG"] = {
"docExpansion": "none",
"validatorUrl": "https://www.b.com"
}
```

Swagger supports many configuration items.
For more information on Swagger Configuration,
please refer to [Swagger Configuration](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md).

```python
app = OpenAPI(
__name__,
swagger_config={
"docExpansion": "none",
"validatorUrl": "https://www.b.com"
}
)
```

## Interactive documentation

!!! Deprecated-Warning warning

`api_doc_url` will be renamed to `doc_url` in v4.x, and `swagger_url`, `redoc_url`, `rapidoc_url` will be removed.


**Flask OpenAPI3** provides support for the following Interactive documentation:

- [Swagger](https://github.com/swagger-api/swagger-ui)
- [Redoc](https://github.com/Redocly/redoc)
- [RapiDoc](https://github.com/rapi-doc/RapiDoc)

The following are the default values of these configurations. Of course, you can change them:

- doc_prefix = "/openapi"
- api_doc_url = "/openapi.json"
- swagger_url= "/swagger"
- redoc_url = "/redoc"
- rapidoc_url = "/rapidoc"

## servers

An array of Server Objects, which provide connectivity information to a target server. If the server's property is not provided, or is an empty array, the default value would be a Server Object with an url value of /.
Expand Down
Loading