microsoft / microsoft/kiota

Add option to generate public/internal setters for generated models for Testing scenarios

Open
#4,392 7 comments 0 reactions 0 assignees View on GitHub
Csharp needs more information type:question
Dominant language
C#
Stars
3.8k
Forks
333
Avg merge
16h 29m
Merged PRs (30d)
116

Description

Hi,

I would like to be able to stub a client generated by Kiota. But, currently, the models has private setters, like this:

I use OpenAPI spec: `kiota search microsoft.com:cognitiveservices-NewsSearch`

```csharp
namespace NewsSearch.Sdk.Models {
public class NewsTopic : Thing, IParsable {
/// A Boolean value that indicates whether the topic is considered breaking news. If the topic is considered breaking news, the value is true.
public bool? IsBreakingNews { get; private set; }
/// The URL to the Bing News search results for the search query term
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public string? NewsSearchUrl { get; private set; }
#nullable restore
#else
public string NewsSearchUrl { get; private set; }
#endif
/// Defines a search query.
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public NewsSearch.Sdk.Models.Query? Query { get; set; }
#nullable restore
#else
public NewsSearch.Sdk.Models.Query Query { get; set; }
#endif

// omitted
}
}

```

I would like to suggest adding a configuration that allows control aspects of model generation.

Thank you, I appreciate your work.

Contributor guide

Open the contributing guide

Research direction

The issue shows generated C# model properties from the NewsSearch OpenAPI example, but names no generator files or tests. Start by locating Kiota's C# model-generation entry point and its existing configuration options; done means a documented option controls whether generated model setters are private, internal, or public, with coverage for the selected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
devtools, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.