Auto-generate ConfigurationSchema.json for JSON IntelliSense#10139
Auto-generate ConfigurationSchema.json for JSON IntelliSense#10139JoshLove-msft merged 25 commits intomainfrom
Conversation
Add schema generation for appsettings.json IntelliSense when a client library has ClientSettings. The schema includes well-known client names under 'Clients' (SCM) or 'AzureClients' (Azure) sections, with $ref to shared credential/options definitions and allOf for client-specific option extensions. Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/555ac5bb-bd9c-4d73-90ca-f2922cf55fa5
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/555ac5bb-bd9c-4d73-90ca-f2922cf55fa5
...sharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/ConfigurationSchemaGenerator.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/555ac5bb-bd9c-4d73-90ca-f2922cf55fa5
.chronus/changes/auto-generate-configuration-schema-json-2026-03-25.md
Outdated
Show resolved
Hide resolved
…rator The base emitter should not contain Azure-specific code. Removed the namespace-based Azure detection and made Generate() always use "Clients" and "options" as defaults, with parameters allowing overrides by derived emitters. Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/78f8c1a0-1d00-4e19-89d1-e9090dc2aeab
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/7703f03f-8937-43a3-b716-e0e5f8090658
|
@copilot why didn't the regen show a diff since we don't have a ConfigurationSchema.json checked in for the Test Project? |
commit: |
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/54e740be-2cdd-4b28-9516-7744e0fcf1dc Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
I hadn't run Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
But why didn't the Regen check step fail on the diff then? |
|
...p-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/schema/ConfigurationSchema.json
Show resolved
Hide resolved
Use ReplaceLineEndings to ensure consistent LF line endings across platforms and append trailing newline to match prettier expectations. Regenerated all ConfigurationSchema.json files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@copilot CI is somehow failing on the git diff check on linux:
Untracked files detected: |
…itive on README.md Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/ff462cc0-505c-42c6-8027-7678fda9721b Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
The untracked file check was scoped to the entire |
...p-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/schema/ConfigurationSchema.json
Outdated
Show resolved
Hide resolved
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/26d73adf-067b-48e0-b996-36827bf3f448 Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
|
@copilot we need to update the version of SCM that we use as dependency to 1.10.0. Do this for both the generated dep and the dep of the generator itself. |
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/320087f6-326c-40aa-a821-d6efac9b11cb Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Updated in 010e432:
|
...r/TestProjects/Spector/http/authentication/http/custom/src/Authentication.Http.Custom.csproj
Show resolved
Hide resolved
- Generate .targets file alongside ConfigurationSchema.json in WriteAdditionalFiles - Add PackItems support to CSharpProjectWriter for NuGet pack items - Add pack items to NewProjectScaffolding for schema + .targets files - Swap order: write additional files before project scaffolding so schema exists Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| "Options": { | ||
| "$ref": "#/definitions/sampleTypeSpecClientOptions" | ||
| } | ||
| } |
There was a problem hiding this comment.
missing "additionalProperties": true before the close of each client like Notebooks
- [x] Add `WriteAdditionalFiles()` virtual method to `CodeModelGenerator` - [x] Create `ConfigurationSchemaGenerator` class in `Microsoft.TypeSpec.Generator.ClientModel` - [x] Override `WriteAdditionalFiles()` in `ScmCodeModelGenerator` to invoke schema generation - [x] Hook into `CSharpGen.ExecuteAsync()` to write additional output files - [x] Add 19 unit tests for ConfigurationSchemaGenerator (all passing) - [x] Verify all existing tests still pass - [x] Code review feedback: Remove Azure-specific logic from base emitter - [x] Code review feedback: Delete chronus changelog file - [x] Run regeneration to generate ConfigurationSchema.json for test projects - [x] Common definitions (`credential`, `options`) are inherited from the [System.ClientModel base schema](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/schema/ConfigurationSchema.json) and referenced via `$ref` — not duplicated locally - [x] Add local `definitions` for additional non-base types (e.g., enums, models used as custom option properties) referenced via `$ref` - [x] Model options type inheritance: each client's options type is a named local definition that extends the base `options` via `allOf` (matching the Azure emitter pattern from azure-sdk-for-net#57548) - [x] Re-run generation to update all ConfigurationSchema.json files - [x] Update `Check-GitChanges.ps1` to also detect new untracked files so the CI regen check catches newly generated files - [x] Add test cases for options types with additional properties (string, integer, and multiple mixed types) - [x] Add test case and support for options properties that contain model definitions (with properties exposed in local `definitions`) - [x] Add test case for model type used as a constructor parameter (appears as top-level client property with `$ref` to local definition) - [x] Verify ConfigurationSchema.json works end-to-end via local pack and JSON Schema draft-07 meta-validation - [x] Use `m is ModelProvider` instead of `!(m is EnumProvider)` for precise type checking - [x] Add null check for `Path.GetDirectoryName` result in `WriteAdditionalFiles` - [x] Add TestData golden file validation for 3 representative tests - [x] Fix CI: scope untracked file check to `generator/` directory to avoid false positive on README.md - [x] Remove `$schema` line from generated ConfigurationSchema.json output (not needed since the consuming tool already knows the schema version) - [x] Update System.ClientModel dependency to 1.10.0 for both the generator itself and generated project scaffolding <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Co-authored-by: jolov <jolov@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
WriteAdditionalFiles()virtual method toCodeModelGeneratorConfigurationSchemaGeneratorclass inMicrosoft.TypeSpec.Generator.ClientModelWriteAdditionalFiles()inScmCodeModelGeneratorto invoke schema generationCSharpGen.ExecuteAsync()to write additional output filescredential,options) are inherited from the System.ClientModel base schema and referenced via$ref— not duplicated locallydefinitionsfor additional non-base types (e.g., enums, models used as custom option properties) referenced via$refoptionsviaallOf(matching the Azure emitter pattern from azure-sdk-for-net#57548)Check-GitChanges.ps1to also detect new untracked files so the CI regen check catches newly generated filesdefinitions)$refto local definition)m is ModelProviderinstead of!(m is EnumProvider)for precise type checkingPath.GetDirectoryNameresult inWriteAdditionalFilesgenerator/directory to avoid false positive on README.md$schemaline from generated ConfigurationSchema.json output (not needed since the consuming tool already knows the schema version)💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.