microsoft / microsoft/kiota

add support for overlays in kiota

Open
#6,727 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement generator help wanted type:enhancement
Dominant language
C#
Stars
3.8k
Forks
333
Avg merge
16h 29m
Merged PRs (30d)
116

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the option definitions and command entry points in src/kiota/KiotaHost.cs, KiotaClientCommands.cs, and KiotaPluginCommands.cs, then trace the generate handler into GenerationConfiguration.cs. Review OpenApiDocumentDownloadService.cs and WorkspaceManagementService.cs, along with the RPC server and TypeScript API entry points. Done means overlays are accepted across the listed commands and APIs, applied during document loading, cached, and covered by OpenApiDocumentDownloadServiceTests.cs.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi, typescript
Domain
api, backend, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.