Skip to content

Fast.OpenApi 公开 API

目标 net8.0;net9.0;net10.0。本页为语法声明与 XML 注释参考,运行示例和边界见模块用法

源码提交:43554c07f6c216f80b509bd535c0a5b66ae7f2e8。维护流程:scripts/export-dotnet-api.ps1;普通站点构建直接消费此文件。

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentSchemaPropertyDto

OpenAPI 文档声明属性 DTO

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto.Type

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Type { get; set; }

类型

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto.Format

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Format { get; set; }

格式

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto.Nullable

源码 · 目标:net8.0、net9.0、net10.0

csharp
public bool Nullable { get; set; }

可为空

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto.ReadOnly

源码 · 目标:net8.0、net9.0、net10.0

csharp
public bool ReadOnly { get; set; }

只读

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto.Description

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Description { get; set; }

描述

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto.Items

源码 · 目标:net8.0、net9.0、net10.0

csharp
public OpenApiDocumentSchemaPropertyDto Items { get; set; }

声明项

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto.Properties

源码 · 目标:net8.0、net9.0、net10.0

csharp
public IDictionary<string, OpenApiDocumentSchemaPropertyDto> Properties { get; set; }

对象属性定义。

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto.Required

源码 · 目标:net8.0、net9.0、net10.0

csharp
public HashSet<string> Required { get; set; }

必填属性名称。

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto.AdditionalProperties

源码 · 目标:net8.0、net9.0、net10.0

csharp
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
    public JsonElement AdditionalProperties { get; set; }

附加属性定义。

说明:OpenAPI 允许该值为布尔值或架构对象,因此保留原始 JSON 结构。

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto.AllOf

源码 · 目标:net8.0、net9.0、net10.0

csharp
public List<OpenApiDocumentSchemaPropertyDto> AllOf { get; set; }

全部匹配的组合架构。

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto.AnyOf

源码 · 目标:net8.0、net9.0、net10.0

csharp
public List<OpenApiDocumentSchemaPropertyDto> AnyOf { get; set; }

任一匹配的组合架构。

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto.OneOf

源码 · 目标:net8.0、net9.0、net10.0

csharp
public List<OpenApiDocumentSchemaPropertyDto> OneOf { get; set; }

唯一匹配的组合架构。

Fast.OpenApi.OpenApiDocumentSchemaPropertyDto.Ref

源码 · 目标:net8.0、net9.0、net10.0

csharp
[JsonPropertyName("$ref")]
    public string Ref { get; set; }

引用

Fast.OpenApi.OpenApiDocumentComponentDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentComponentDto

OpenAPI 文档组件 DTO

Fast.OpenApi.OpenApiDocumentComponentDto.Schemas

源码 · 目标:net8.0、net9.0、net10.0

csharp
public IDictionary<string, OpenApiDocumentComponentSchemaDto> Schemas { get; set; }

声明

Fast.OpenApi.OpenApiDocumentComponentSchemaDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentComponentSchemaDto

OpenAPI 文档组件声明 DTO

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.Enum

源码 · 目标:net8.0、net9.0、net10.0

csharp
public List<long> Enum { get; set; }

枚举

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.Type

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Type { get; set; }

类型

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.Format

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Format { get; set; }

格式

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.Nullable

源码 · 目标:net8.0、net9.0、net10.0

csharp
public bool Nullable { get; set; }

可为空。

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.Items

源码 · 目标:net8.0、net9.0、net10.0

csharp
public OpenApiDocumentSchemaPropertyDto Items { get; set; }

声明项。

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.Properties

源码 · 目标:net8.0、net9.0、net10.0

csharp
public IDictionary<string, OpenApiDocumentSchemaPropertyDto> Properties { get; set; }

架构属性定义

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.Required

源码 · 目标:net8.0、net9.0、net10.0

csharp
public HashSet<string> Required { get; set; }

必填属性名称。

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.AdditionalProperties

源码 · 目标:net8.0、net9.0、net10.0

csharp
[JsonIgnore]
    public bool AdditionalProperties { get; set; }

附加属性

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.AdditionalPropertiesSchema

源码 · 目标:net8.0、net9.0、net10.0

csharp
[JsonPropertyName("additionalProperties")]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
    public JsonElement AdditionalPropertiesSchema { get; set; }

附加属性的原始定义。

说明:用于同时兼容 OpenAPI 中的布尔值和架构对象。

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.Ref

源码 · 目标:net8.0、net9.0、net10.0

csharp
[JsonPropertyName("$ref")]
    public string Ref { get; set; }

引用。

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.AllOf

源码 · 目标:net8.0、net9.0、net10.0

csharp
public List<OpenApiDocumentSchemaPropertyDto> AllOf { get; set; }

全部匹配的组合架构。

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.AnyOf

源码 · 目标:net8.0、net9.0、net10.0

csharp
public List<OpenApiDocumentSchemaPropertyDto> AnyOf { get; set; }

任一匹配的组合架构。

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.OneOf

源码 · 目标:net8.0、net9.0、net10.0

csharp
public List<OpenApiDocumentSchemaPropertyDto> OneOf { get; set; }

唯一匹配的组合架构。

Fast.OpenApi.OpenApiDocumentComponentSchemaDto.Description

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Description { get; set; }

描述

Fast.OpenApi.OpenApiDocumentDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentDto

OpenAPI 文档 DTO

Fast.OpenApi.OpenApiDocumentDto.Url

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Url { get; set; }

地址

说明:

Fast.OpenApi.OpenApiDocumentDto.OpenApi

源码 · 目标:net8.0、net9.0、net10.0

csharp
[JsonPropertyName("openapi")]
    public string OpenApi { get; set; }

OpenAPI 版本

Fast.OpenApi.OpenApiDocumentDto.Info

源码 · 目标:net8.0、net9.0、net10.0

csharp
public OpenApiDocumentInfoDto Info { get; set; }

文档信息

Fast.OpenApi.OpenApiDocumentDto.Paths

源码 · 目标:net8.0、net9.0、net10.0

csharp
public IDictionary<string, OpenApiDocumentPathDto> Paths { get; set; }

路由

Fast.OpenApi.OpenApiDocumentDto.Components

源码 · 目标:net8.0、net9.0、net10.0

csharp
public OpenApiDocumentComponentDto Components { get; set; }

组件

Fast.OpenApi.OpenApiDocumentDto.Tags

源码 · 目标:net8.0、net9.0、net10.0

csharp
public List<OpenApiDocumentTagDto> Tags { get; set; }

模块

Fast.OpenApi.OpenApiDocumentInfoDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentInfoDto

OpenAPI 文档信息 DTO

Fast.OpenApi.OpenApiDocumentInfoDto.Title

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Title { get; set; }

标题

Fast.OpenApi.OpenApiDocumentInfoDto.Description

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Description { get; set; }

描述

Fast.OpenApi.OpenApiDocumentInfoDto.Version

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Version { get; set; }

版本

Fast.OpenApi.OpenApiDocumentPathDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentPathDto

OpenAPI 文档路由 DTO

Fast.OpenApi.OpenApiDocumentPathDto.Get

源码 · 目标:net8.0、net9.0、net10.0

csharp
public OpenApiDocumentPathMethodDto Get { get; set; }

Get 请求

Fast.OpenApi.OpenApiDocumentPathDto.Post

源码 · 目标:net8.0、net9.0、net10.0

csharp
public OpenApiDocumentPathMethodDto Post { get; set; }

Post 请求

Fast.OpenApi.OpenApiDocumentPathDto.Method

源码 · 目标:net8.0、net9.0、net10.0

csharp
public OpenApiDocumentPathMethodDto Method { get; }

请求方法

Fast.OpenApi.OpenApiDocumentPathDto.RequestMethod

源码 · 目标:net8.0、net9.0、net10.0

csharp
public HttpRequestMethodEnum RequestMethod { get; }

请求方式

Fast.OpenApi.OpenApiDocumentPathDto.Tag

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Tag { get; }

模块

Fast.OpenApi.OpenApiDocumentPathMethodDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentPathMethodDto

OpenAPI 文档路由请求方法 DTO

Fast.OpenApi.OpenApiDocumentPathMethodDto.Tags

源码 · 目标:net8.0、net9.0、net10.0

csharp
public List<string> Tags { get; set; }

模块

说明:这里一般默认获取第一个即可

Fast.OpenApi.OpenApiDocumentPathMethodDto.Summary

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Summary { get; set; }

接口名称

Fast.OpenApi.OpenApiDocumentPathMethodDto.OperationId

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string OperationId { get; set; }

操作Id

Fast.OpenApi.OpenApiDocumentPathMethodDto.Parameters

源码 · 目标:net8.0、net9.0、net10.0

csharp
public List<OpenApiDocumentPathMethodParameterDto> Parameters { get; set; }

URL 参数

Fast.OpenApi.OpenApiDocumentPathMethodDto.RequestBody

源码 · 目标:net8.0、net9.0、net10.0

csharp
public OpenApiDocumentPathMethodRequestBodyDto RequestBody { get; set; }

Body 参数

Fast.OpenApi.OpenApiDocumentPathMethodDto.Responses

源码 · 目标:net8.0、net9.0、net10.0

csharp
public OpenApiDocumentPathMethodResponseDto Responses { get; set; }

响应

Fast.OpenApi.OpenApiDocumentPathMethodContentDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentPathMethodContentDto

OpenAPI 文档路由内容 DTO

Fast.OpenApi.OpenApiDocumentPathMethodContentDto.Json

源码 · 目标:net8.0、net9.0、net10.0

csharp
[JsonPropertyName("application/json")]
    public OpenApiDocumentPathMethodContentSchemaDto Json { get; set; }

JSON 格式

Fast.OpenApi.OpenApiDocumentPathMethodContentDto.FormData

源码 · 目标:net8.0、net9.0、net10.0

csharp
[JsonPropertyName("multipart/form-data")]
    public OpenApiDocumentPathMethodContentSchemaDto FormData { get; set; }

表单格式

Fast.OpenApi.OpenApiDocumentPathMethodContentSchemaDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentPathMethodContentSchemaDto

OpenAPI 文档路由内容声明 DTO

Fast.OpenApi.OpenApiDocumentPathMethodContentSchemaDto.Schema

源码 · 目标:net8.0、net9.0、net10.0

csharp
public OpenApiDocumentSchemaPropertyDto Schema { get; set; }

声明

Fast.OpenApi.OpenApiDocumentPathMethodParameterDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentPathMethodParameterDto

OpenAPI 文档路由请求方法参数 DTO

Fast.OpenApi.OpenApiDocumentPathMethodParameterDto.Name

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Name { get; set; }

参数名称

Fast.OpenApi.OpenApiDocumentPathMethodParameterDto.In

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string In { get; set; }

参数来源位置,例如 query、path、header 或 cookie

Fast.OpenApi.OpenApiDocumentPathMethodParameterDto.Description

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Description { get; set; }

描述

Fast.OpenApi.OpenApiDocumentPathMethodParameterDto.Schema

源码 · 目标:net8.0、net9.0、net10.0

csharp
public OpenApiDocumentSchemaPropertyDto Schema { get; set; }

声明

Fast.OpenApi.OpenApiDocumentPathMethodRequestBodyDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentPathMethodRequestBodyDto

OpenAPI 文档路由请求体 DTO

Fast.OpenApi.OpenApiDocumentPathMethodRequestBodyDto.Description

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Description { get; set; }

描述

Fast.OpenApi.OpenApiDocumentPathMethodRequestBodyDto.Content

源码 · 目标:net8.0、net9.0、net10.0

csharp
public OpenApiDocumentPathMethodContentDto Content { get; set; }

请求体内容

Fast.OpenApi.OpenApiDocumentPathMethodResponseContentDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentPathMethodResponseContentDto

OpenAPI 文档路由响应内容 DTO

Fast.OpenApi.OpenApiDocumentPathMethodResponseContentDto.Description

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Description { get; set; }

描述

Fast.OpenApi.OpenApiDocumentPathMethodResponseContentDto.Content

源码 · 目标:net8.0、net9.0、net10.0

csharp
public OpenApiDocumentPathMethodContentDto Content { get; set; }

内容

Fast.OpenApi.OpenApiDocumentPathMethodResponseDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentPathMethodResponseDto

OpenAPI 文档路由响应 DTO

Fast.OpenApi.OpenApiDocumentPathMethodResponseDto.Description

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Description { get; set; }

描述

Fast.OpenApi.OpenApiDocumentPathMethodResponseDto.Code200

源码 · 目标:net8.0、net9.0、net10.0

csharp
[JsonPropertyName("200")]
    public OpenApiDocumentPathMethodResponseContentDto Code200 { get; set; }

响应码 200 内容

Fast.OpenApi.OpenApiDocumentTagDto

源码 · 目标:net8.0、net9.0、net10.0

csharp
public class OpenApiDocumentTagDto

OpenAPI 文档模块 DTO

Fast.OpenApi.OpenApiDocumentTagDto.Name

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Name { get; set; }

模块名称

Fast.OpenApi.OpenApiDocumentTagDto.Description

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Description { get; set; }

描述

Fast.OpenApi.ScriptLanguageEnum

源码 · 目标:net8.0、net9.0、net10.0

csharp
public enum ScriptLanguageEnum : byte

脚本语言枚举

Fast.OpenApi.ScriptLanguageEnum.JavaScript

源码 · 目标:net8.0、net9.0、net10.0

csharp
[Description("JavaScript")]
    JavaScript = 1

JavaScript

Fast.OpenApi.ScriptLanguageEnum.TypeScript

源码 · 目标:net8.0、net9.0、net10.0

csharp
[Description("TypeScript")]
    TypeScript = 2

TypeScript

Fast.OpenApi.IServiceCollectionExtension

源码 · 目标:net8.0、net9.0、net10.0

csharp
[SuppressSniffer]
public static class IServiceCollectionExtension

IServiceCollection 提供动态 API 扩展方法

Fast.OpenApi.IServiceCollectionExtension.AddOpenApi

源码 · 目标:net8.0、net9.0、net10.0

csharp
public static IServiceCollection AddOpenApi(this IServiceCollection services, IConfiguration configuration,
        string section = "OpenApiSettings")

添加 OpenAPI 设置

说明:适用于只使用工具类

  • 参数 services:要添加服务的服务集合
  • 参数 configuration:用于读取模块设置的配置
  • 参数 section:JSON 配置文件节点的 Key 默认值:OpenAPISettings
  • 返回:返回 services,便于链式调用

Fast.OpenApi.OpenApiSettingsOptions

源码 · 目标:net8.0、net9.0、net10.0

csharp
[SuppressSniffer]
public class OpenApiSettingsOptions : IPostConfigure

OpenAPI 配置

Fast.OpenApi.OpenApiSettingsOptions.FolderGroup

源码 · 目标:net8.0、net9.0、net10.0

csharp
public bool? FolderGroup { get; set; }

文件夹分组

Fast.OpenApi.OpenApiSettingsOptions.ImportSchemaMappings

源码 · 目标:net8.0、net9.0、net10.0

csharp
public List<OpenApiImportSchemaMappingSettingsOptions> ImportSchemaMappings { get; set; }

导入声明映射

说明:导出也只会会忽略

Fast.OpenApi.OpenApiSettingsOptions.ImportTypeMappings

源码 · 目标:net8.0、net9.0、net10.0

csharp
public List<OpenApiImportTypeMappingSettingsOptions> ImportTypeMappings { get; set; }

导入类型声明

Fast.OpenApi.OpenApiSettingsOptions.IgnoreSchemas

源码 · 目标:net8.0、net9.0、net10.0

csharp
public HashSet<string> IgnoreSchemas { get; set; }

忽略声明

Fast.OpenApi.OpenApiSettingsOptions.PagedSchemaProperties

源码 · 目标:net8.0、net9.0、net10.0

csharp
public HashSet<string> PagedSchemaProperties { get; set; }

分页声明属性

Fast.OpenApi.OpenApiSettingsOptions.BaseTypeMappings

源码 · 目标:net8.0、net9.0、net10.0

csharp
public IDictionary<string, string> BaseTypeMappings { get; set; }

基础类型映射

Fast.OpenApi.OpenApiSettingsOptions.PostConfigure

源码 · 目标:net8.0、net9.0、net10.0

csharp
public void PostConfigure()

说明继承自接口或基类,需结合对应声明阅读。

Fast.OpenApi.OpenApiImportSchemaMappingSettingsOptions

源码 · 目标:net8.0、net9.0、net10.0

csharp
[SuppressSniffer]
public class OpenApiImportSchemaMappingSettingsOptions

OpenAPI 导入声明映射配置

Fast.OpenApi.OpenApiImportSchemaMappingSettingsOptions.Name

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Name { get; set; }

名称

Fast.OpenApi.OpenApiImportSchemaMappingSettingsOptions.MappingName

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string MappingName { get; set; }

映射名称

说明:为空默认取 Name

Fast.OpenApi.OpenApiImportSchemaMappingSettingsOptions.WebImportPath

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string WebImportPath { get; set; }

Web 端导入路径

Fast.OpenApi.OpenApiImportSchemaMappingSettingsOptions.MobileImportPath

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string MobileImportPath { get; set; }

移动端导入路径

Fast.OpenApi.OpenApiImportTypeMappingSettingsOptions

源码 · 目标:net8.0、net9.0、net10.0

csharp
[SuppressSniffer]
public class OpenApiImportTypeMappingSettingsOptions

OpenAPI 导入类型映射配置

Fast.OpenApi.OpenApiImportTypeMappingSettingsOptions.Name

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string Name { get; set; }

名称(开头)

Fast.OpenApi.OpenApiImportTypeMappingSettingsOptions.MappingName

源码 · 目标:net8.0、net9.0、net10.0

csharp
public string MappingName { get; set; }

映射名称

说明:{0}取名称截取后的所有字符

Fast.OpenApi.OpenApiImportTypeMappingSettingsOptions.RefSchema

源码 · 目标:net8.0、net9.0、net10.0

csharp
public HashSet<string> RefSchema { get; set; }

引用声明

Fast.OpenApi.OpenApiUtil

源码 · 目标:net8.0、net9.0、net10.0

csharp
public static partial class OpenApiUtil

OpenAPI API 工具类

Fast.OpenApi.OpenApiUtil

源码 · 目标:net8.0、net9.0、net10.0

csharp
public static partial class OpenApiUtil

OpenAPI DTO 工具类

Fast.OpenApi.OpenApiUtil

源码 · 目标:net8.0、net9.0、net10.0

csharp
public static partial class OpenApiUtil

OpenAPI 枚举工具类

Fast.OpenApi.OpenApiUtil

源码 · 目标:net8.0、net9.0、net10.0

csharp
public static partial class OpenApiUtil

OpenAPI 工具类

Fast.OpenApi.OpenApiUtil.GenerateOpenApi

源码 · 目标:net8.0、net9.0、net10.0

csharp
public static async Task GenerateOpenApi(string address,
        IApiDescriptionGroupCollectionProvider apiDescriptionGroupCollectionProvider, List<string> groupList = null)

生成 OpenAPI 文档资源

  • 参数 address:目标服务地址
  • 参数 apiDescriptionGroupCollectionProvider:用于读取所有 API 描述分组的提供器
  • 参数 groupList:文档分组集合
  • 返回:表示异步“生成 OpenAPI 文档资源”操作的任务

Fast.OpenApi.OpenApiUtil

源码 · 目标:net8.0、net9.0、net10.0

csharp
public static partial class OpenApiUtil

OpenAPI 请求工具类