Swagger UI
Swagger UI` 属性被用来在 Port实体中引用和显示OpenAPI 和/或AsyncAPI 规范文件。
使用该属性将自动在每个entity page 中创建一个附加选项卡,以Swagger UI 格式显示规范文件。在该选项卡中,您可以直接从 Port 对规范目标执行 HTTP 调用。
下面是实体页面中 "Swagger UI "选项卡的示例:
OpenAPI
定义
- URL
- JSON
- YAML
使用 URL 格式时,Port 将查询所引用 URL 的 OpenAPI 规范,并希望得到 JSON OpenAPI 规范
在使用 URL 进行 open-api
显示时,请确保您的服务器允许来自 app.getport.io
的跨源 (CORS) 请求。
要从 AWS S3 存储桶提供 OpenAPI 规范,请向存储桶添加 CORS 策略,允许来自 app.getport.io
的请求,请查看AWS documentation 了解更多信息。
- API
- Terraform
{
"myOpenApi": {
"title": "My Open API",
"type": "string",
"format": "url",
"spec": "open-api",
"description": "Open-API Prop"
}
}
resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties {
identifier = "myOpenApi"
title = "My Open Api"
required = false
type = "string"
format = "url"
spec = "open-api"
}
}
使用 JSON 类型时,您需要将完整的 JSON OpenAPI 规范作为一个对象提供给实体:
- API
- Terraform
{
"myOpenApi": {
"title": "My Open API",
"type": "object",
"spec": "open-api",
"description": "Open-API Prop"
}
}
resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
props_object = {
myOpenApi = {
title = "My Open Api"
required = false
spec = "open-api"
}
}
}
}
使用 YAML 类型时,您需要向实体提供完整的 YAML OpenAPI 规范:
- API
- Terraform
{
"myOpenApi": {
"title": "My Open API",
"type": "string",
"format": "yaml",
"spec": "open-api",
"description": "Open-API Prop"
}
}
resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
string_props = {
"myYamlProp" = {
title = "My yaml"
required = false
format = "yaml"
}
}
}
}
示例
以下是提供 OpenAPI 规范时,特定实体页面中 Swagger 标签的显示方式:
AsyncAPI
定义
- URL
- JSON
- YAML
当使用 URL 格式时,Port 将查询 Provider 提供的 URL 以获取 AsyncAPI 规范,并期望得到 JSON AsyncAPI 规范
当使用 URL 显示 "async-api "时,请确保您的服务器允许来自 "app.getport.io "的跨源 (CORS) 请求
要从 AWS S3 存储桶提供 OpenAPI 规范,请向存储桶添加 CORS 策略,允许来自 app.getport.io
的请求,请查看AWS documentation 了解更多信息。
- API
- Terraform
{
"myAsyncApi": {
"title": "My Async API",
"type": "string",
"format": "url",
"spec": "async-api",
"description": "async-api Prop"
}
}
resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties {
identifier = "myAsyncApi"
title = "My Async API"
required = false
type = "string"
format = "url"
spec = "async-api"
}
}
使用 JSON 类型时,需要将完整的 JSON AsyncAPI 规范作为一个对象提供给 Entity:
- API
- Terraform
{
"myAsyncApi": {
"title": "My Async API",
"type": "object",
"spec": "async-api",
"description": "async-api Prop"
}
}
resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
props_object = {
myAsyncApi = {
title = "My Async Api"
required = false
spec = "async-api"
}
}
}
}
使用 YAML 类型时,您需要向实体提供完整的 YAML AsyncAPI 规范:
- API
- Terraform
{
"myOpenApi": {
"title": "My Async API",
"type": "string",
"format": "yaml",
"spec": "async-api",
"description": "Async-API Prop"
}
}
resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
string_props = {
"myYamlProp" = {
title = "My yaml"
required = false
format = "yaml"
}
}
}
}
示例
以下是提供 AsyncAPI 规范时,特定实体页面中 Swagger 标签的显示方式: