配置参考
Bundle 配置存储在您的应用程序配置中的 nelmio_api_doc
键下。
1 2 3 4 5
# displays the default config values
$ php bin/console config:dump-reference nelmio_api_doc
# displays the actual config values used by your application
$ php bin/console debug:config nelmio_api_doc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
# Example default configuration
nelmio_api_doc:
# Whether to use the symfony/type-info component for determining types.
type_info: false
# If true, `groups` passed to #[Model] attributes will be used to limit validation constraints
use_validation_groups: false
cache:
# define cache pool to use
pool: null
# define cache item id
item_id: null
# The documentation to use as base
documentation:
# Example:
# info:
# title: 'My App'
# description: 'My App Description'
# List of enabled Media Types
media_types:
- json
# UI configuration options
html_config:
assets_mode: cdn
# https://swagger.org.cn/docs/open-source-tools/swagger-ui/usage/configuration/
swagger_ui_config: []
# https://redocly.com/docs/redoc/config/
redocly_config: []
# https://docs.stoplight.io/docs/elements/b074dc47b2826-elements-configuration-options
stoplight_config: []
# Filter the routes that are documented
areas:
default:
path_patterns:
# Examples:
# - ^/api
# - '^/api(?!/admin)'
host_patterns:
# Example:
# - ^api\.
name_patterns:
# Example:
# - ^api_v1
# whether to filter by attributes
with_attribute: false
# if set disables default routes without attributes
disable_default_routes: false
# The base documentation used for the area
documentation:
# Example:
# info:
# title: 'My App'
# description: 'My App Description'
cache:
# define cache pool to use for the area
pool: null
# define cache item id for the area
item_id: null
models:
use_jms: false
names:
-
alias: ~ # Example: 'Foo'
type: ~ # Example: 'App\Foo'
groups: null
options: null
serializationContext: []
areas: []
配置
type_info
类型: boolean
默认值: false
是否使用 symfony/type-info 来确定类型。
提示
如果您使用的是 Symfony 7.2 或更高版本,则应将此选项设置为 true
。因为这可以大大提高类型检测。
4.35
对 symfony/type-info 的支持在 4.35 版本中添加。
cache
类型: dictionary
允许的键: pool
, item_id
用于生成文档的缓存配置。
1 2 3 4 5 6 7 8
nelmio_api_doc:
# ...
cache:
# define cache pool to use
pool: 'cache.app'
# define cache item id
item_id: 'nelmio_api_doc_cache'
documentation
类型: dictionary
用作基础的 API 文档。
1 2 3 4 5 6 7 8
nelmio_api_doc:
# ...
documentation:
# Any valid OpenAPI/Swagger documentation
info:
title: 'My App'
description: 'My App Description'
html_config
类型: dictionary
默认值: []
允许的键: assets_mode
, swagger_ui_config
, redocly_config
, stoplight_config
UI 配置选项。
1 2 3 4 5 6 7 8 9 10 11
nelmio_api_doc:
# ...
html_config:
assets_mode: 'cdn'
# https://swagger.org.cn/docs/open-source-tools/swagger-ui/usage/configuration/
swagger_ui_config: []
# https://redocly.com/docs/redoc/config/
redocly_config: []
# https://docs.stoplight.io/docs/elements/b074dc47b2826-elements-configuration-options
stoplight_config: []
4.37
`stoplight_config` 选项在 4.37 版本中添加。
areas
类型: dictionary
过滤要记录的路由。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
nelmio_api_doc:
# ...
areas:
default:
path_patterns:
# Examples:
# - ^/api
# - '^/api(?!/admin)'
host_patterns:
# Example:
# - ^api\.
name_patterns:
# Example:
# - ^api_v1
with_attribute: false
disable_default_routes: false
documentation:
# Example:
# info:
# title: 'My App'
# description: 'My App Description'
cache:
# define cache pool to use for the area
pool: null
# define cache item id for the area
item_id: null
with_annotation
类型: boolean
默认值: false
是否仅记录带有 #[Areas]
注解/属性的路由。
4.36
with_annotation
在 4.36 版本中已弃用。请改用 with_attribute
。
models
类型: dictionary
模型的配置。
names
类型: list
模型列表,这可以用于:- 定义未自动检测到的模型。- 为模型创建自定义别名(模式名称)。(基于 groups/options/serializationContext/areas)
1 2 3 4 5 6 7 8 9 10 11 12
nelmio_api_doc:
# ...
models:
use_jms: false
names:
-
# Alias the class 'App\Foo' to 'FooPrivate' for the 'private' group
alias: 'FooPrivate'
type: 'App\Foo'
groups:
- 'private'