api-platform / api-platform/core

Ability to override/configure OpenAPI servers

オープン
#8,029 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
OpenAPI
主要言語
PHP
スター
2.6k
フォーク
980
平均マージ
2日 2時間
マージ済み PR(30日)
51

説明

**Description**
I would like to be able to define a list of specific server endpoints (environments) against which my OpenAPI schema can operate against.

**Example**
I should be able to use a decorator to override the default servers listing so that I can have a list of servers within my openapi.json schema export. For example:

```
final class JwtDecorator implements OpenApiFactoryInterface
{
public function __construct(
private OpenApiFactoryInterface $decorated
) {
}

public function __invoke(array $context = []): OpenApi
{
$context['servers'] = [
new Model\Server('https://docker.local/', 'Docker'),
new Model\Server('https://app-dev.company.com/', 'Dev'),
new Model\Server('https://app-staging.company.com/', 'Staging'),
new Model\Server('https://app.company.com/', 'Production'),
];
return ($this->decorated)($context);
}
}
```

After running the export:
`./bin/console api:openapi:export --output=openapi.json`

And upon reviewing the openapi.json file:
```
{
"openapi": "3.0.3",
"info": {
"title": "App",
"description": "description",
"version": "version"
},
"servers": [
{
"url": "https://docker.local/",
"description": "Docker"
},
{
"url": "https://app-dev.company.com/",
"description": "Dev"
},
{
"url": "https://app-staging.company.com/",
"description": "Staging"
},
{
"url": "https://app.company.com/",
"description": "Production"
}
]
```

![image](https://user-images.githubusercontent.com/1039875/137376147-0928a273-b59f-462e-9d2c-9beff291729c.png)

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。