-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.Net: Samples showing use of allOf, anyof and oneOf (#9697)
### Motivation and Context Related to #8997 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
- Loading branch information
1 parent
f4b6ac1
commit 5197f0b
Showing
5 changed files
with
404 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
dotnet/samples/Concepts/Resources/Plugins/PetsPlugin/allOfV3.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
{ | ||
"openapi": "3.0.1", | ||
"info": { | ||
"title": "Pets API", | ||
"version": "1.0.0", | ||
"description": "API for managing pets." | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "https://api.yourdomain.com" | ||
} | ||
], | ||
"paths": { | ||
"/pets": { | ||
"patch": { | ||
"summary": "Update a pet. Call this with either details for a dog or a cat but not both.", | ||
"description": "Update a pet. Call this with either details for a dog or a cat but not both.", | ||
"operationId": "updatePet", | ||
"requestBody": { | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"oneOf": [ | ||
{ "$ref": "#/components/schemas/Cat" }, | ||
{ "$ref": "#/components/schemas/Dog" } | ||
], | ||
"discriminator": { | ||
"propertyName": "pet_type" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"200": { | ||
"description": "Updated" | ||
} | ||
} | ||
}, | ||
"post": { | ||
"summary": "Create a pet. Call this with either details for a dog or a cat but not both.", | ||
"description": "Create a pet. Call this with either details for a dog or a cat but not both.", | ||
"operationId": "createPet", | ||
"requestBody": { | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"oneOf": [ | ||
{ "$ref": "#/components/schemas/Cat" }, | ||
{ "$ref": "#/components/schemas/Dog" } | ||
], | ||
"discriminator": { | ||
"propertyName": "pet_type" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"201": { | ||
"description": "Created" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"Pet": { | ||
"type": "object", | ||
"required": [ "pet_type" ], | ||
"properties": { | ||
"pet_type": { | ||
"type": "string" | ||
} | ||
}, | ||
"discriminator": { | ||
"propertyName": "pet_type" | ||
} | ||
}, | ||
"Dog": { | ||
"allOf": [ | ||
{ "$ref": "#/components/schemas/Pet" }, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"bark": { | ||
"type": "boolean" | ||
}, | ||
"breed": { | ||
"type": "string", | ||
"enum": [ "Dingo", "Husky", "Retriever", "Shepherd" ] | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"Cat": { | ||
"allOf": [ | ||
{ "$ref": "#/components/schemas/Pet" }, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"hunts": { | ||
"type": "boolean" | ||
}, | ||
"age": { | ||
"type": "integer" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
dotnet/samples/Concepts/Resources/Plugins/PetsPlugin/anyOfV3.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
"openapi": "3.0.1", | ||
"info": { | ||
"title": "Pets API", | ||
"version": "1.0.0", | ||
"description": "API for managing pets." | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "https://api.yourdomain.com" | ||
} | ||
], | ||
"paths": { | ||
"/pets": { | ||
"patch": { | ||
"summary": "Update a pet. Call this with either details for a dog or a cat but not both.", | ||
"description": "Update a pet. Call this with either details for a dog or a cat but not both.", | ||
"operationId": "updatePet", | ||
"requestBody": { | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"anyOf": [ | ||
{ "$ref": "#/components/schemas/PetByAge" }, | ||
{ "$ref": "#/components/schemas/PetByType" } | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"200": { | ||
"description": "Updated" | ||
} | ||
} | ||
}, | ||
"put": { | ||
"summary": "Create a pet. Call this with either details for a dog or a cat but not both.", | ||
"description": "Create a pet. Call this with either details for a dog or a cat but not both.", | ||
"operationId": "createPet", | ||
"requestBody": { | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"anyOf": [ | ||
{ "$ref": "#/components/schemas/PetByAge" }, | ||
{ "$ref": "#/components/schemas/PetByType" } | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"201": { | ||
"description": "Create" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"PetByAge": { | ||
"type": "object", | ||
"properties": { | ||
"age": { | ||
"type": "integer" | ||
}, | ||
"nickname": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ "age" ] | ||
}, | ||
"PetByType": { | ||
"type": "object", | ||
"properties": { | ||
"pet_type": { | ||
"type": "string", | ||
"enum": [ "Cat", "Dog" ] | ||
}, | ||
"hunts": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"required": [ "pet_type" ] | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.