Part 3, The Kiota Side Quest Harder than I thought

TL;DR – The official Mistral OpenAPI spec is 49,000 lines. Kiota’s –include-path flag filters it at generation time to the one endpoint I care about. The question was never “how do I shrink this file”. It was “how do I ask for less”. Along the way I got a Ferrari when I wanted a go-kart, plus a free sample of tool-calling scaffolding that pays off later in the series.

This is a small diversion from the main series, but it is the insight the whole project turned on. This post is the long-form version of the side quest; with the reasoning I skipped on stage. Buried in the model’s failed attempts, its reasoning kept naming Kiota, Microsoft’s OpenAPI client generator.

First attempt so many files

kiota generate --language CSharp
  --class-name MistralChatCompletionClient
  --namespace-name Mistral
  --openapi mistral-openapi.yaml

Second attempt 3% of the original count

kiota generate --language CSharp
  --class-name MistralChatCompletionClient
  --namespace-name Mistral
  --openapi mistral-openapi.yaml
  --output Generated
  --include-path "/v1/chat/completions*"

The interesting commandline flag is –include-path. The full 49,000-line spec, filtered at generation time to one endpoint. I did not edit the YAML. I did not trim anything by hand. I told the generator what I wanted and it brought back only that.

Bonus, the newer snapshot generated the response-side cache-hit field. One snapshot can send prompt_cache_key, the other cannot report the hit. Two downloads of “the same” file (days apart), and they disagree about what the API says back.

Full spec‘–include-path “/v1/chat/completions*”
.cs files2,39069
Lines of C#257,7416,463
Directories3035
Intersection-type wrappers3420
Generation time~35s~3s

Because the number of files was so big, I ran a cyclomatic complexity analyser over the two libraries.

Full spec (2,390 files)Chat only (69 files)
Total cyclomatic complexity~18,233~488
Total decision points~15,843~419
Average CC per file7.67.1
Files over CC 103788
Worst fileUsageQueryRowOUT.cs, CC ~189ChatCompletionRequest.cs, CC ~152

Complexity scales with breadth, not depth. Average complexity per file is nearly identical between the two (7.6 vs 7.1). The full client is not harder to read per file, there are just 37x more files. The worst offenders are serialization sinks. UsageQueryRowOUT (CC ~189), ExtendedOAuthServerMetadata (~188), CreateResponseResponse (~157), ChatCompletionRequest (~152).

The Kiota 1.39 generates for .NET 10, so an older standalone .NET 8 or 9 runtime will crash at startup with a MissingMethodException from the diagnostics stack. Point DOTNET_ROOT at a .NET 10 runtime and it runs clean.

I compared my fresh download against a generated client from a different snapshot of the same spec, taken weeks apart. One snapshot has RAG deployments, their metrics and the Vespa deployment models. The other has dataset-records bulk operations, workflow deployment archives, and a pile of new admin workspace-member models.

There were also a surprising number of warnings.

PS C:\Users\BrynLewis\Downloads\Kiota> kiota generate --language CSharp --class-name MistralChatCompletionClient --namespace-name Mistral --openapi openapi.yaml --output Generated --include-path "/v1/chat/completions*"
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/ - The schema PipelineConfigDefinition is a polymorphic type but does not define a discriminator. This will result in serialization errors.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/ - The schema EmbeddingInput is a polymorphic type but does not define a discriminator. This will result in serialization errors.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/ - The schema OutputContentChunks is a polymorphic type but does not define a discriminator. This will result in serialization errors.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/ - The schema ChatClassificationRequestInputs is a polymorphic type but does not define a discriminator. This will result in serialization errors.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/ - The schema EvaluatorStatistics is a polymorphic type but does not define a discriminator. This will result in serialization errors.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/ - The schema /v1/workflows/{workflow_identifier}/execute is a polymorphic type but does not define a discriminator. This will result in serialization errors.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/ - The schema /v1/workflows/registrations/{workflow_registration_id}/execute is a polymorphic type but does not define a discriminator. This will result in serialization errors.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/ - The schema /v1/conversations/{conversation_id} is a polymorphic type but does not define a discriminator. This will result in serialization errors.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/ClientSecret/properties/value - The format password is not supported by Kiota for the type String and will be ignored.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/AudioTranscriptionRequest/properties/file_url/anyOf/0 - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/AudioTranscriptionRequestStream/properties/file_url/anyOf/0 - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/AuthData/properties/client_secret/anyOf/0 - The format password is not supported by Kiota for the type String and will be ignored.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/ConnectorMCPPublicUpdate/properties/server/anyOf/0 - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/ExtendedOAuthServerMetadata/properties/issuer - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/ExtendedOAuthServerMetadata/properties/authorization_endpoint/anyOf/0 - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/ExtendedOAuthServerMetadata/properties/token_endpoint - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/ExtendedOAuthServerMetadata/properties/registration_endpoint/anyOf/0 - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/ExtendedOAuthServerMetadata/properties/service_documentation/anyOf/0 - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/ExtendedOAuthServerMetadata/properties/op_policy_uri/anyOf/0 - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/ExtendedOAuthServerMetadata/properties/op_tos_uri/anyOf/0 - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/ExtendedOAuthServerMetadata/properties/revocation_endpoint/anyOf/0 - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/ExtendedOAuthServerMetadata/properties/introspection_endpoint/anyOf/0 - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/OAuth2ClientCredentialsInput/properties/client_secret/anyOf/0 - The format password is not supported by Kiota for the type String and will be ignored.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/OAuth2ClientCredentialsInput/properties/client_private_key/anyOf/0 - The format password is not supported by Kiota for the type String and will be ignored.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/Oauth2MetadataSecrets/properties/client_secret/anyOf/0 - The format password is not supported by Kiota for the type String and will be ignored.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/CreateConnectorRequest/properties/oauth2_server_metadata_url/anyOf/0 - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/CreateConnectorRequest/properties/server - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/CreateHTTPConnectorRequest/properties/oauth2_server_metadata_url/anyOf/0 - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/CreateHTTPConnectorRequest/properties/server - The format uri is not supported by Kiota and the string type will be used.
warn: Kiota.Builder.KiotaBuilder[534942631]
      OpenAPI warning: #/components/schemas/UpdateHTTPConnectorRequest/properties/server/anyOf/0 - The format uri is not supported by Kiota and the string type will be used.
Generation skipped as no changes were detected

Hint: to force the generation to overwrite an existing client pass the --clean-output switch.
Example: kiota generate --clean-output

Hint: use the info command to get the list of dependencies you need to add to your project.
Example: kiota info -d "C:\Users\BrynLewis\Downloads\Kiota\openapi.yaml" -l CSharp
PS C:\Users\BrynLewis\Downloads\Kiota>

Next in the series: Part 4, the human as the clipboard, file tools, permissioning, and the CLI demo where the tool-calling scaffolding parked here finally earns its keep.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.