Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added model generation for schemas used by OpenAPI 3.1 webhooks. [#6394](https://github.com/microsoft/kiota/issues/6394)
- Adds support for resolving JSON Schema 2020-12 `$dynamicRef` against schemas declaring `$dynamicAnchor`, so recursive types (e.g. `LocalizedCategory.children: LocalizedCategory[]`) generate correctly instead of degrading to `UntypedNode`. Phase 1 of [#7815](https://github.com/microsoft/kiota/issues/7815).
- Added binding-aware `$dynamicRef` resolution for `$defs` / `$dynamicAnchor` contexts, generating distinct concrete models for each active binding and preserving typed request bodies, responses, and error responses. Phase 2 of [#7815](https://github.com/microsoft/kiota/issues/7815).

### Changed

Expand Down
162 changes: 122 additions & 40 deletions src/Kiota.Builder/KiotaBuilder.cs

Large diffs are not rendered by default.

404 changes: 404 additions & 0 deletions tests/Kiota.Builder.IntegrationTests/GenerateSample.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,54 @@
<None Update="non-identifier-schema-key.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="generic-binding.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="inline-binding.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="recursive-generic-binding.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="request-body-generic-binding.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="multi-anchor-generic-binding.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="unresolved-dynamicref.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="array-root-dynamicref.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="inherited-generic-binding.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="request-response-inline-binding.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="multi-error-inline-binding.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="multi-inline-binding.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="mixed-anchor-binding.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="nested-dynamic-scope.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="inherited-component-binding.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="no-operation-id-inline-binding.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="namespaced-binding.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
59 changes: 59 additions & 0 deletions tests/Kiota.Builder.IntegrationTests/array-root-dynamicref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
openapi: 3.1.0
info:
title: DynamicRef Array Root Generic Binding API
version: 0.1.0
paths:
/users/list:
get:
operationId: listUsersArray
responses:
'200':
description: Array of users via dynamic ref
content:
application/json:
schema:
$defs:
itemType:
$dynamicAnchor: itemType
$ref: '#/components/schemas/User'
type: array
items:
$dynamicRef: '#itemType'
default:
description: Error
/groups/list:
get:
operationId: listGroupsArray
responses:
'200':
description: Array of groups via dynamic ref
content:
application/json:
schema:
$defs:
itemType:
$dynamicAnchor: itemType
$ref: '#/components/schemas/Group'
type: array
items:
$dynamicRef: '#itemType'
default:
description: Error
components:
schemas:
User:
type: object
required: [id, name]
properties:
id:
type: string
name:
type: string
Group:
type: object
required: [id, label]
properties:
id:
type: string
label:
type: string
89 changes: 89 additions & 0 deletions tests/Kiota.Builder.IntegrationTests/generic-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
openapi: 3.1.0
info:
title: DynamicRef Generic Binding API
version: 0.1.0
paths:
/users:
get:
operationId: listUsers
responses:
'200':
description: User page
content:
application/json:
schema:
$defs:
itemType:
$dynamicAnchor: itemType
$ref: '#/components/schemas/User'
$ref: '#/components/schemas/PaginatedTemplate'
default:
description: Error
/groups:
get:
operationId: listGroups
responses:
'200':
description: Group page
content:
application/json:
schema:
$defs:
itemType:
$dynamicAnchor: itemType
$ref: '#/components/schemas/Group'
$ref: '#/components/schemas/PaginatedTemplate'
default:
description: Error
/profiles:
get:
operationId: listProfiles
responses:
'200':
description: Profile page
content:
application/json:
schema:
$defs:
itemType:
$dynamicAnchor: itemType
$ref: '#/components/schemas/user-profile'
$ref: '#/components/schemas/PaginatedTemplate'
default:
description: Error
components:
schemas:
User:
type: object
required: [id, name]
properties:
id:
type: string
name:
type: string
Group:
type: object
required: [id, label]
properties:
id:
type: string
label:
type: string
user-profile:
type: object
required: [id, displayName]
properties:
id:
type: string
displayName:
type: string
PaginatedTemplate:
$id: https://example.com/schemas/PaginatedTemplate
$dynamicAnchor: itemType
type: object
required: [items]
properties:
items:
type: array
items:
$dynamicRef: '#itemType'
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
openapi: 3.1.0
info:
title: DynamicRef Inherited Component Binding API
version: 0.1.0
paths:
/pages/users:
get:
operationId: listUserPages
responses:
'200':
description: User page
content:
application/json:
schema:
$defs:
itemType:
$dynamicAnchor: itemType
$ref: '#/components/schemas/User'
$ref: '#/components/schemas/DerivedPage'
/pages/groups:
get:
operationId: listGroupPages
responses:
'200':
description: Group page
content:
application/json:
schema:
$defs:
itemType:
$dynamicAnchor: itemType
$ref: '#/components/schemas/Group'
$ref: '#/components/schemas/DerivedPage'
components:
schemas:
User:
type: object
properties:
id:
type: string
Group:
type: object
properties:
id:
type: string
BasePage:
$dynamicAnchor: itemType
type: object
properties:
items:
type: array
items:
$dynamicRef: '#itemType'
DerivedPage:
allOf:
- $ref: '#/components/schemas/BasePage'
- type: object
properties:
page:
type: integer
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
openapi: 3.1.0
info:
title: DynamicRef Inherited Generic Binding API
version: 0.1.0
paths:
/inherited/users:
get:
operationId: listInheritedUsers
responses:
'200':
description: User page
content:
application/json:
schema:
$defs:
itemType:
$dynamicAnchor: itemType
$ref: '#/components/schemas/User'
$ref: '#/components/schemas/InheritedTemplate'
default:
description: Error
/inherited/groups:
get:
operationId: listInheritedGroups
responses:
'200':
description: Group page
content:
application/json:
schema:
$defs:
itemType:
$dynamicAnchor: itemType
$ref: '#/components/schemas/Group'
$ref: '#/components/schemas/InheritedTemplate'
default:
description: Error
components:
schemas:
User:
type: object
required: [id, name]
properties:
id:
type: string
name:
type: string
Group:
type: object
required: [id, label]
properties:
id:
type: string
label:
type: string
PageBase:
type: object
properties:
nextLink:
type: string
InheritedTemplate:
$id: https://example.com/schemas/InheritedTemplate
$dynamicAnchor: itemType
allOf:
- $ref: '#/components/schemas/PageBase'
- type: object
required: [items]
properties:
items:
type: array
items:
$dynamicRef: '#itemType'
Loading