зеркало из https://github.com/microsoft/kiota.git
Added some samples
This commit is contained in:
Родитель
d63c85e976
Коммит
e701eaf6b6
|
@ -24,7 +24,7 @@ public class GenerateSample
|
|||
{
|
||||
Language = language,
|
||||
OpenAPIFilePath = "ToDoApi.yaml",
|
||||
OutputPath = $".\\Generated\\{language}{backingStoreSuffix}",
|
||||
OutputPath = $".\\Generated\\Todo\\{language}{backingStoreSuffix}",
|
||||
UsesBackingStore = backingStore,
|
||||
};
|
||||
await new KiotaBuilder(logger, configuration).GenerateSDK(new());
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="ModelWithDerivedTypes.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ModelWithDictionary.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
openapi: 3.0.0
|
||||
info:
|
||||
title: "Derived Types API"
|
||||
version: "1.0.0"
|
||||
servers:
|
||||
- url: https://example.org/
|
||||
paths:
|
||||
/fruits: # this method will not downcast to OpenAPI v2 because oneOf is not supported
|
||||
get:
|
||||
responses:
|
||||
200:
|
||||
description: ok
|
||||
content:
|
||||
application/json:
|
||||
# The code generator will need to be clever and instead of generating a fruitResponse class
|
||||
# with a property for each of the properties, it needs to detect that apple and orange derive from fruit.
|
||||
# It can then declare the requestExecutors as returning the base type.
|
||||
schema:
|
||||
oneOf:
|
||||
- $ref: "#/components/schemas/fruit" # Allowing the base class allows enables evolvabilty
|
||||
- $ref: "#/components/schemas/apple"
|
||||
- $ref: "#/components/schemas/orange"
|
||||
/fruitsWithDiscriminator:
|
||||
get:
|
||||
responses:
|
||||
200:
|
||||
description: ok
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
discriminator:
|
||||
propertyName: fruitType # This only works if fruitType has the exact schema name
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/fruit" # Allowing the base class allows enables evolvabilty
|
||||
/fruitsWithDiscriminatorWithMapping:
|
||||
get:
|
||||
responses:
|
||||
200:
|
||||
description: ok
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
discriminator:
|
||||
propertyName: fruitType
|
||||
mapping: # If mapping doesn't exist, then fallback to base type'
|
||||
apple: '#/components/schemas/apple'
|
||||
orange: '#/components/schemas/orange'
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/fruit" # Allowing the base class allows enables evolvabilty
|
||||
|
||||
components:
|
||||
schemas:
|
||||
fruit:
|
||||
type: object
|
||||
title: fruit # required temporarily due to a bug in Kiota codemodel
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
fruitType:
|
||||
type: string
|
||||
apple:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/fruit'
|
||||
type: object
|
||||
title: apple
|
||||
properties:
|
||||
edible:
|
||||
type: boolean
|
||||
fruitType:
|
||||
x-const: apple # the const keyword is only supported int OpenAPI 3.1
|
||||
orange:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/fruit'
|
||||
type: object
|
||||
title: orange
|
||||
properties:
|
||||
seedless:
|
||||
type: boolean
|
||||
fruitType:
|
||||
x-const: orange
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
openapi: 3.0.0
|
||||
info:
|
||||
title: "API that returns multiple response formats"
|
||||
version: "1.0.0"
|
||||
servers:
|
||||
- url: https://example.org/
|
||||
paths:
|
||||
/report:
|
||||
get:
|
||||
responses:
|
||||
200:
|
||||
description: ok
|
||||
content:
|
||||
application/json: {} # Response is JSON but no schema is defined
|
||||
text/csv: {}
|
||||
/reportWithSchema:
|
||||
get:
|
||||
responses:
|
||||
200:
|
||||
description: ok
|
||||
content:
|
||||
application/json: # Response is JSON but no schema is defined
|
||||
schema:
|
||||
$ref: "#/components/schemas/weatherReport"
|
||||
text/csv: {}
|
||||
components:
|
||||
schemas:
|
||||
weatherReport:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
date:
|
||||
type: string
|
||||
temperature:
|
||||
type: string
|
||||
conditions:
|
||||
type: string
|
Загрузка…
Ссылка в новой задаче