microsoft/kiota

add support for overlays in kiota

Open

#6,727 创建于 2025年7月7日

在 GitHub 查看
 (0 评论) (0 反应) (0 负责人)C# (326 fork)auto 404
enhancementgeneratorhelp wantedtype:enhancement

仓库指标

Star
 (3,783 star)
PR 合并指标
 (PR 指标待抓取)

描述

OpenAPI overlays allow people to maintain patches to an OpenAPI description in a separate document. This is especially useful when the person generating a client is not the one authoring the OpenAPI description, and they don't want to maintain in sync their own modified copy. This topic has come in discussions times and times again see: #6687 #6451 #5073 #3406 #411 and many more.

To implement overlays we first need to:

declare a new option

Name "overlay". Supports multiple values. Defaults to an empty array/list. full name --overlay Short name --ov

https://github.com/microsoft/kiota/blob/0772a6e5746ae8a264fcda6626a7d667bbf55916/src/kiota/KiotaHost.cs#L427

use that option in commands

pass the option to handlers

Example with generate

(do the same with client/plugin add/edit commands)

Add the option to the generation configuration

https://github.com/microsoft/kiota/blob/0772a6e5746ae8a264fcda6626a7d667bbf55916/src/Kiota.Builder/Configuration/GenerationConfiguration.cs#L117

Add the option to the RPC server

https://github.com/microsoft/kiota/blob/0772a6e5746ae8a264fcda6626a7d667bbf55916/src/kiota/Rpc/Server.cs#L156

(same for plugins)

add the option in the TypeScript API

https://github.com/microsoft/kiota/blob/0772a6e5746ae8a264fcda6626a7d667bbf55916/vscode/packages/npm-package/lib/generateClient.ts#L57

(same for plugins)

add the dependency to the csproj

Add BinkyLabs.OpenAPI.Overlays to src/kiota.builder/kiota.builder.csproj

Intercept the loading and apply the overlays

https://github.com/microsoft/kiota/blob/0772a6e5746ae8a264fcda6626a7d667bbf55916/src/Kiota.Builder/OpenApiDocumentDownloadService.cs#L140

Add some unit tests

https://github.com/microsoft/kiota/blob/main/tests/Kiota.Builder.Tests/OpenApiDocumentDownloadServiceTests.cs

store the overlays with the workspace service (caching)

https://github.com/microsoft/kiota/blob/main/src/Kiota.Builder/WorkspaceManagement/WorkspaceManagementService.cs

贡献者指南