Added multiple-inheritance code and tests.
This commit is contained in:
Родитель
5d29447024
Коммит
7bd08cf9b2
|
@ -0,0 +1,106 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using AutoRest.TestServer.Tests.Infrastructure;
|
||||
using multiple_inheritance;
|
||||
using multiple_inheritance.Models;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
{
|
||||
[IgnoreOnTestServer(TestServerVersion.V2, "Requests not matched")]
|
||||
public class MultipleInheritanceTest : TestServerTestBase
|
||||
{
|
||||
public MultipleInheritanceTest(TestServerVersion version) : base(version, "multipleInheritance") { }
|
||||
|
||||
[Test]
|
||||
public Task MultipleInheritanceCatGet() => Test(async (host, pipeline) =>
|
||||
{
|
||||
var result = await new ServiceClient(ClientDiagnostics, pipeline, host).RestClient.GetCatAsync();
|
||||
Assert.AreEqual("Whiskers", result.Value.Name);
|
||||
Assert.IsTrue(result.Value.LikesMilk);
|
||||
Assert.IsTrue(result.Value.Meows);
|
||||
Assert.IsTrue(result.Value.Hisses);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task MultipleInheritanceCatPut() => Test(async (host, pipeline) =>
|
||||
{
|
||||
var value = new Cat("Boots", false, true, false);
|
||||
var result = await new ServiceClient(ClientDiagnostics, pipeline, host).RestClient.PutCatAsync(value);
|
||||
Assert.AreEqual(200, result.GetRawResponse().Status);
|
||||
Assert.AreEqual("Cat was correct!", result.Value);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task MultipleInheritanceFelineGet() => Test(async (host, pipeline) =>
|
||||
{
|
||||
var result = await new ServiceClient(ClientDiagnostics, pipeline, host).RestClient.GetFelineAsync();
|
||||
Assert.IsTrue(result.Value.Meows);
|
||||
Assert.IsTrue(result.Value.Hisses);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task MultipleInheritanceFelinePut() => Test(async (host, pipeline) =>
|
||||
{
|
||||
var value = new Feline(false, true);
|
||||
var result = await new ServiceClient(ClientDiagnostics, pipeline, host).RestClient.PutFelineAsync(value);
|
||||
Assert.AreEqual(200, result.GetRawResponse().Status);
|
||||
Assert.AreEqual("Feline was correct!", result.Value);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task MultipleInheritanceHorseGet() => Test(async (host, pipeline) =>
|
||||
{
|
||||
var result = await new ServiceClient(ClientDiagnostics, pipeline, host).RestClient.GetHorseAsync();
|
||||
Assert.AreEqual("Fred", result.Value.Name);
|
||||
Assert.IsTrue(result.Value.IsAShowHorse);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task MultipleInheritanceHorsePut() => Test(async (host, pipeline) =>
|
||||
{
|
||||
var value = new Horse("General", false);
|
||||
var result = await new ServiceClient(ClientDiagnostics, pipeline, host).RestClient.PutHorseAsync(value);
|
||||
Assert.AreEqual(200, result.GetRawResponse().Status);
|
||||
Assert.AreEqual("Horse was correct!", result.Value);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task MultipleInheritanceKittenGet() => Test(async (host, pipeline) =>
|
||||
{
|
||||
var result = await new ServiceClient(ClientDiagnostics, pipeline, host).RestClient.GetKittenAsync();
|
||||
Assert.AreEqual("Gatito", result.Value.Name);
|
||||
Assert.IsTrue(result.Value.LikesMilk);
|
||||
Assert.IsTrue(result.Value.Meows);
|
||||
Assert.IsTrue(result.Value.Hisses);
|
||||
Assert.IsFalse(result.Value.EatsMiceYet);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task MultipleInheritanceKittenPut() => Test(async (host, pipeline) =>
|
||||
{
|
||||
var value = new Kitten("Kitty", false, true, false, true);
|
||||
var result = await new ServiceClient(ClientDiagnostics, pipeline, host).RestClient.PutKittenAsync(value);
|
||||
Assert.AreEqual(200, result.GetRawResponse().Status);
|
||||
Assert.AreEqual("Kitten was correct!", result.Value);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task MultipleInheritancePetGet() => Test(async (host, pipeline) =>
|
||||
{
|
||||
var result = await new ServiceClient(ClientDiagnostics, pipeline, host).RestClient.GetPetAsync();
|
||||
Assert.AreEqual("Peanut", result.Value.Name);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task MultipleInheritancePetPut() => Test(async (host, pipeline) =>
|
||||
{
|
||||
var value = new Pet("Butter");
|
||||
var result = await new ServiceClient(ClientDiagnostics, pipeline, host).RestClient.PutPetAsync(value);
|
||||
Assert.AreEqual(200, result.GetRawResponse().Status);
|
||||
Assert.AreEqual("Pet was correct!", result.Value);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,10 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using AutoRest.TestServer.Tests.Infrastructure;
|
||||
using Azure;
|
||||
|
|
|
@ -0,0 +1,911 @@
|
|||
!<!CodeModel>
|
||||
info: !<!Info>
|
||||
description: Service client for multiinheritance client testing
|
||||
title: Multiple Inheritance Service Client
|
||||
schemas: !<!Schemas>
|
||||
booleans:
|
||||
- !<!BooleanSchema> &ref_2
|
||||
type: boolean
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: Boolean
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
numbers:
|
||||
- !<!NumberSchema> &ref_8
|
||||
type: integer
|
||||
precision: 32
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: Integer
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
strings:
|
||||
- !<!StringSchema> &ref_0
|
||||
type: string
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: String
|
||||
description: simple string
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!StringSchema> &ref_7
|
||||
type: string
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: PetName
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!StringSchema> &ref_9
|
||||
type: string
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ErrorMessage
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!StringSchema> &ref_14
|
||||
type: string
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: String
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
constants:
|
||||
- !<!ConstantSchema> &ref_12
|
||||
type: constant
|
||||
value: !<!ConstantValue>
|
||||
value: application/json
|
||||
valueType: *ref_0
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ApplicationJson
|
||||
description: Content Type 'application/json'
|
||||
protocol: !<!Protocols> {}
|
||||
objects:
|
||||
- !<!ObjectSchema> &ref_1
|
||||
type: object
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
children: !<!Relations>
|
||||
all:
|
||||
- !<!ObjectSchema> &ref_6
|
||||
type: object
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
parents: !<!Relations>
|
||||
all:
|
||||
- *ref_1
|
||||
immediate:
|
||||
- *ref_1
|
||||
properties:
|
||||
- !<!Property>
|
||||
schema: *ref_2
|
||||
serializedName: isAShowHorse
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: isAShowHorse
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
serializationFormats:
|
||||
- json
|
||||
usage:
|
||||
- output
|
||||
- input
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: Horse
|
||||
description: ''
|
||||
namespace: ''
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!ObjectSchema> &ref_3
|
||||
type: object
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
children: !<!Relations>
|
||||
all:
|
||||
- !<!ObjectSchema> &ref_4
|
||||
type: object
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
parents: !<!Relations>
|
||||
all:
|
||||
- *ref_3
|
||||
- *ref_1
|
||||
- !<!ObjectSchema> &ref_5
|
||||
type: object
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
children: !<!Relations>
|
||||
all:
|
||||
- *ref_3
|
||||
- *ref_4
|
||||
- *ref_4
|
||||
immediate:
|
||||
- *ref_3
|
||||
properties:
|
||||
- !<!Property>
|
||||
schema: *ref_2
|
||||
serializedName: meows
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: meows
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!Property>
|
||||
schema: *ref_2
|
||||
serializedName: hisses
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: hisses
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
serializationFormats:
|
||||
- json
|
||||
usage:
|
||||
- output
|
||||
- input
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: Feline
|
||||
description: ''
|
||||
namespace: ''
|
||||
protocol: !<!Protocols> {}
|
||||
- *ref_1
|
||||
- *ref_5
|
||||
immediate:
|
||||
- *ref_3
|
||||
properties:
|
||||
- !<!Property>
|
||||
schema: *ref_2
|
||||
serializedName: eatsMiceYet
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: eatsMiceYet
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
serializationFormats:
|
||||
- json
|
||||
usage:
|
||||
- output
|
||||
- input
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: Kitten
|
||||
description: ''
|
||||
namespace: ''
|
||||
protocol: !<!Protocols> {}
|
||||
immediate:
|
||||
- *ref_4
|
||||
parents: !<!Relations>
|
||||
all:
|
||||
- *ref_1
|
||||
- *ref_5
|
||||
- *ref_1
|
||||
- *ref_5
|
||||
immediate:
|
||||
- *ref_1
|
||||
- *ref_5
|
||||
properties:
|
||||
- !<!Property>
|
||||
schema: *ref_2
|
||||
serializedName: likesMilk
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: likesMilk
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
serializationFormats:
|
||||
- json
|
||||
usage:
|
||||
- output
|
||||
- input
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: Cat
|
||||
description: ''
|
||||
namespace: ''
|
||||
protocol: !<!Protocols> {}
|
||||
- *ref_4
|
||||
- *ref_4
|
||||
immediate:
|
||||
- *ref_6
|
||||
- *ref_3
|
||||
properties:
|
||||
- !<!Property>
|
||||
schema: *ref_7
|
||||
required: true
|
||||
serializedName: name
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: name
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
serializationFormats:
|
||||
- json
|
||||
usage:
|
||||
- output
|
||||
- input
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: Pet
|
||||
description: ''
|
||||
namespace: ''
|
||||
protocol: !<!Protocols> {}
|
||||
- *ref_6
|
||||
- !<!ObjectSchema> &ref_11
|
||||
type: object
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
properties:
|
||||
- !<!Property>
|
||||
schema: *ref_8
|
||||
serializedName: status
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: status
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!Property>
|
||||
schema: *ref_9
|
||||
serializedName: message
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: message
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
serializationFormats:
|
||||
- json
|
||||
usage:
|
||||
- output
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: Error
|
||||
description: ''
|
||||
namespace: ''
|
||||
protocol: !<!Protocols> {}
|
||||
- *ref_5
|
||||
- *ref_3
|
||||
- *ref_4
|
||||
globalParameters:
|
||||
- !<!Parameter> &ref_10
|
||||
schema: *ref_0
|
||||
clientDefaultValue: 'http://localhost:3000'
|
||||
implementation: Client
|
||||
origin: 'modelerfour:synthesized/host'
|
||||
required: true
|
||||
extensions:
|
||||
x-ms-skip-url-encoding: true
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: $host
|
||||
description: server parameter
|
||||
serializedName: $host
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: uri
|
||||
operationGroups:
|
||||
- !<!OperationGroup>
|
||||
$key: ''
|
||||
operations:
|
||||
- !<!Operation>
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
parameters:
|
||||
- *ref_10
|
||||
requests:
|
||||
- !<!Request>
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpRequest>
|
||||
path: /multipleInheritance/horse
|
||||
method: get
|
||||
uri: '{$host}'
|
||||
signatureParameters: []
|
||||
responses:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_6
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- '200'
|
||||
exceptions:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_11
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- default
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: GetHorse
|
||||
description: Get a horse with name 'Fred' and isAShowHorse true
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!Operation>
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
parameters:
|
||||
- *ref_10
|
||||
requests:
|
||||
- !<!Request>
|
||||
parameters:
|
||||
- !<!Parameter>
|
||||
schema: *ref_12
|
||||
implementation: Method
|
||||
origin: 'modelerfour:synthesized/content-type'
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: contentType
|
||||
description: Body Parameter content-type
|
||||
serializedName: Content-Type
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: header
|
||||
- !<!Parameter> &ref_13
|
||||
schema: *ref_6
|
||||
implementation: Method
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: horse
|
||||
description: Put a horse with name 'General' and isAShowHorse false
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: body
|
||||
style: json
|
||||
signatureParameters:
|
||||
- *ref_13
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpWithBodyRequest>
|
||||
path: /multipleInheritance/horse
|
||||
method: put
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
uri: '{$host}'
|
||||
signatureParameters: []
|
||||
responses:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_14
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- '200'
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: PutHorse
|
||||
description: Put a horse with name 'General' and isAShowHorse false
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!Operation>
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
parameters:
|
||||
- *ref_10
|
||||
requests:
|
||||
- !<!Request>
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpRequest>
|
||||
path: /multipleInheritance/pet
|
||||
method: get
|
||||
uri: '{$host}'
|
||||
signatureParameters: []
|
||||
responses:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_1
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- '200'
|
||||
exceptions:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_11
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- default
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: GetPet
|
||||
description: Get a pet with name 'Peanut'
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!Operation>
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
parameters:
|
||||
- *ref_10
|
||||
requests:
|
||||
- !<!Request>
|
||||
parameters:
|
||||
- !<!Parameter>
|
||||
schema: *ref_12
|
||||
implementation: Method
|
||||
origin: 'modelerfour:synthesized/content-type'
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: contentType
|
||||
description: Body Parameter content-type
|
||||
serializedName: Content-Type
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: header
|
||||
- !<!Parameter> &ref_15
|
||||
schema: *ref_1
|
||||
implementation: Method
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: pet
|
||||
description: Put a pet with name 'Butter'
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: body
|
||||
style: json
|
||||
signatureParameters:
|
||||
- *ref_15
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpWithBodyRequest>
|
||||
path: /multipleInheritance/pet
|
||||
method: put
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
uri: '{$host}'
|
||||
signatureParameters: []
|
||||
responses:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_14
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- '200'
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: PutPet
|
||||
description: Put a pet with name 'Butter'
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!Operation>
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
parameters:
|
||||
- *ref_10
|
||||
requests:
|
||||
- !<!Request>
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpRequest>
|
||||
path: /multipleInheritance/feline
|
||||
method: get
|
||||
uri: '{$host}'
|
||||
signatureParameters: []
|
||||
responses:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_5
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- '200'
|
||||
exceptions:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_11
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- default
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: GetFeline
|
||||
description: Get a feline where meows and hisses are true
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!Operation>
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
parameters:
|
||||
- *ref_10
|
||||
requests:
|
||||
- !<!Request>
|
||||
parameters:
|
||||
- !<!Parameter>
|
||||
schema: *ref_12
|
||||
implementation: Method
|
||||
origin: 'modelerfour:synthesized/content-type'
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: contentType
|
||||
description: Body Parameter content-type
|
||||
serializedName: Content-Type
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: header
|
||||
- !<!Parameter> &ref_16
|
||||
schema: *ref_5
|
||||
implementation: Method
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: feline
|
||||
description: Put a feline who hisses and doesn't meow
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: body
|
||||
style: json
|
||||
signatureParameters:
|
||||
- *ref_16
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpWithBodyRequest>
|
||||
path: /multipleInheritance/feline
|
||||
method: put
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
uri: '{$host}'
|
||||
signatureParameters: []
|
||||
responses:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_14
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- '200'
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: PutFeline
|
||||
description: Put a feline who hisses and doesn't meow
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!Operation>
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
parameters:
|
||||
- *ref_10
|
||||
requests:
|
||||
- !<!Request>
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpRequest>
|
||||
path: /multipleInheritance/cat
|
||||
method: get
|
||||
uri: '{$host}'
|
||||
signatureParameters: []
|
||||
responses:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_3
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- '200'
|
||||
exceptions:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_11
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- default
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: GetCat
|
||||
description: 'Get a cat with name ''Whiskers'' where likesMilk, meows, and hisses is true'
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!Operation>
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
parameters:
|
||||
- *ref_10
|
||||
requests:
|
||||
- !<!Request>
|
||||
parameters:
|
||||
- !<!Parameter>
|
||||
schema: *ref_12
|
||||
implementation: Method
|
||||
origin: 'modelerfour:synthesized/content-type'
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: contentType
|
||||
description: Body Parameter content-type
|
||||
serializedName: Content-Type
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: header
|
||||
- !<!Parameter> &ref_17
|
||||
schema: *ref_3
|
||||
implementation: Method
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: cat
|
||||
description: 'Put a cat with name ''Boots'' where likesMilk and hisses is false, meows is true'
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: body
|
||||
style: json
|
||||
signatureParameters:
|
||||
- *ref_17
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpWithBodyRequest>
|
||||
path: /multipleInheritance/cat
|
||||
method: put
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
uri: '{$host}'
|
||||
signatureParameters: []
|
||||
responses:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_14
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- '200'
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: PutCat
|
||||
description: 'Put a cat with name ''Boots'' where likesMilk and hisses is false, meows is true'
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!Operation>
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
parameters:
|
||||
- *ref_10
|
||||
requests:
|
||||
- !<!Request>
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpRequest>
|
||||
path: /multipleInheritance/kitten
|
||||
method: get
|
||||
uri: '{$host}'
|
||||
signatureParameters: []
|
||||
responses:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_4
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- '200'
|
||||
exceptions:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_11
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- default
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: GetKitten
|
||||
description: 'Get a kitten with name ''Gatito'' where likesMilk and meows is true, and hisses and eatsMiceYet is false'
|
||||
protocol: !<!Protocols> {}
|
||||
- !<!Operation>
|
||||
apiVersions:
|
||||
- !<!ApiVersion>
|
||||
version: 3.0.0
|
||||
parameters:
|
||||
- *ref_10
|
||||
requests:
|
||||
- !<!Request>
|
||||
parameters:
|
||||
- !<!Parameter>
|
||||
schema: *ref_12
|
||||
implementation: Method
|
||||
origin: 'modelerfour:synthesized/content-type'
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: contentType
|
||||
description: Body Parameter content-type
|
||||
serializedName: Content-Type
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: header
|
||||
- !<!Parameter> &ref_18
|
||||
schema: *ref_4
|
||||
implementation: Method
|
||||
required: true
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: kitten
|
||||
description: 'Put a kitten with name ''Kitty'' where likesMilk and hisses is false, meows and eatsMiceYet is true'
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpParameter>
|
||||
in: body
|
||||
style: json
|
||||
signatureParameters:
|
||||
- *ref_18
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpWithBodyRequest>
|
||||
path: /multipleInheritance/kitten
|
||||
method: put
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
uri: '{$host}'
|
||||
signatureParameters: []
|
||||
responses:
|
||||
- !<!SchemaResponse>
|
||||
schema: *ref_14
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpResponse>
|
||||
knownMediaType: json
|
||||
mediaTypes:
|
||||
- application/json
|
||||
statusCodes:
|
||||
- '200'
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: PutKitten
|
||||
description: 'Put a kitten with name ''Kitty'' where likesMilk and hisses is false, meows and eatsMiceYet is true'
|
||||
protocol: !<!Protocols> {}
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: ''
|
||||
description: ''
|
||||
protocol: !<!Protocols> {}
|
||||
security: !<!Security>
|
||||
authenticationRequired: false
|
||||
language: !<!Languages>
|
||||
default:
|
||||
name: MultipleInheritanceServiceClient
|
||||
description: ''
|
||||
protocol: !<!Protocols>
|
||||
http: !<!HttpModel> {}
|
|
@ -0,0 +1 @@
|
|||
{"OutputFolder":".","Namespace":"multiple_inheritance","LibraryName":"multiple_inheritance","SharedSourceFolder":"..\\..\\..\\src\\assets","AzureArm":false}
|
82
test/TestServerProjects/multiple-inheritance/Generated/Models/Cat.Serialization.cs
сгенерированный
Normal file
82
test/TestServerProjects/multiple-inheritance/Generated/Models/Cat.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,82 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace multiple_inheritance.Models
|
||||
{
|
||||
public partial class Cat : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (LikesMilk != null)
|
||||
{
|
||||
writer.WritePropertyName("likesMilk");
|
||||
writer.WriteBooleanValue(LikesMilk.Value);
|
||||
}
|
||||
if (Meows != null)
|
||||
{
|
||||
writer.WritePropertyName("meows");
|
||||
writer.WriteBooleanValue(Meows.Value);
|
||||
}
|
||||
if (Hisses != null)
|
||||
{
|
||||
writer.WritePropertyName("hisses");
|
||||
writer.WriteBooleanValue(Hisses.Value);
|
||||
}
|
||||
writer.WritePropertyName("name");
|
||||
writer.WriteStringValue(Name);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
internal static Cat DeserializeCat(JsonElement element)
|
||||
{
|
||||
bool? likesMilk = default;
|
||||
bool? meows = default;
|
||||
bool? hisses = default;
|
||||
string name = default;
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("likesMilk"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
likesMilk = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("meows"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
meows = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("hisses"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
hisses = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("name"))
|
||||
{
|
||||
name = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return new Cat(name, likesMilk, meows, hisses);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
|
||||
namespace multiple_inheritance.Models
|
||||
{
|
||||
/// <summary> The Cat. </summary>
|
||||
public partial class Cat : Pet
|
||||
{
|
||||
/// <summary> Initializes a new instance of Cat. </summary>
|
||||
/// <param name="name"> . </param>
|
||||
public Cat(string name) : base(name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of Cat. </summary>
|
||||
/// <param name="name"> . </param>
|
||||
/// <param name="likesMilk"> . </param>
|
||||
/// <param name="meows"> . </param>
|
||||
/// <param name="hisses"> . </param>
|
||||
internal Cat(string name, bool? likesMilk, bool? meows, bool? hisses) : base(name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
LikesMilk = likesMilk;
|
||||
Meows = meows;
|
||||
Hisses = hisses;
|
||||
}
|
||||
|
||||
public bool? LikesMilk { get; set; }
|
||||
public bool? Meows { get; set; }
|
||||
public bool? Hisses { get; set; }
|
||||
}
|
||||
}
|
43
test/TestServerProjects/multiple-inheritance/Generated/Models/Error.Serialization.cs
сгенерированный
Normal file
43
test/TestServerProjects/multiple-inheritance/Generated/Models/Error.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace multiple_inheritance.Models
|
||||
{
|
||||
public partial class Error
|
||||
{
|
||||
internal static Error DeserializeError(JsonElement element)
|
||||
{
|
||||
int? status = default;
|
||||
string message = default;
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("status"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
status = property.Value.GetInt32();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("message"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
message = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return new Error(status, message);
|
||||
}
|
||||
}
|
||||
}
|
30
test/TestServerProjects/multiple-inheritance/Generated/Models/Error.cs
сгенерированный
Normal file
30
test/TestServerProjects/multiple-inheritance/Generated/Models/Error.cs
сгенерированный
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace multiple_inheritance.Models
|
||||
{
|
||||
/// <summary> The Error. </summary>
|
||||
public partial class Error
|
||||
{
|
||||
/// <summary> Initializes a new instance of Error. </summary>
|
||||
internal Error()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of Error. </summary>
|
||||
/// <param name="status"> . </param>
|
||||
/// <param name="message"> . </param>
|
||||
internal Error(int? status, string message)
|
||||
{
|
||||
Status = status;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public int? Status { get; }
|
||||
public string Message { get; }
|
||||
}
|
||||
}
|
59
test/TestServerProjects/multiple-inheritance/Generated/Models/Feline.Serialization.cs
сгенерированный
Normal file
59
test/TestServerProjects/multiple-inheritance/Generated/Models/Feline.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,59 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace multiple_inheritance.Models
|
||||
{
|
||||
public partial class Feline : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (Meows != null)
|
||||
{
|
||||
writer.WritePropertyName("meows");
|
||||
writer.WriteBooleanValue(Meows.Value);
|
||||
}
|
||||
if (Hisses != null)
|
||||
{
|
||||
writer.WritePropertyName("hisses");
|
||||
writer.WriteBooleanValue(Hisses.Value);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
internal static Feline DeserializeFeline(JsonElement element)
|
||||
{
|
||||
bool? meows = default;
|
||||
bool? hisses = default;
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("meows"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
meows = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("hisses"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
hisses = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return new Feline(meows, hisses);
|
||||
}
|
||||
}
|
||||
}
|
30
test/TestServerProjects/multiple-inheritance/Generated/Models/Feline.cs
сгенерированный
Normal file
30
test/TestServerProjects/multiple-inheritance/Generated/Models/Feline.cs
сгенерированный
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace multiple_inheritance.Models
|
||||
{
|
||||
/// <summary> The Feline. </summary>
|
||||
public partial class Feline
|
||||
{
|
||||
/// <summary> Initializes a new instance of Feline. </summary>
|
||||
public Feline()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of Feline. </summary>
|
||||
/// <param name="meows"> . </param>
|
||||
/// <param name="hisses"> . </param>
|
||||
internal Feline(bool? meows, bool? hisses)
|
||||
{
|
||||
Meows = meows;
|
||||
Hisses = hisses;
|
||||
}
|
||||
|
||||
public bool? Meows { get; set; }
|
||||
public bool? Hisses { get; set; }
|
||||
}
|
||||
}
|
52
test/TestServerProjects/multiple-inheritance/Generated/Models/Horse.Serialization.cs
сгенерированный
Normal file
52
test/TestServerProjects/multiple-inheritance/Generated/Models/Horse.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,52 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace multiple_inheritance.Models
|
||||
{
|
||||
public partial class Horse : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (IsAShowHorse != null)
|
||||
{
|
||||
writer.WritePropertyName("isAShowHorse");
|
||||
writer.WriteBooleanValue(IsAShowHorse.Value);
|
||||
}
|
||||
writer.WritePropertyName("name");
|
||||
writer.WriteStringValue(Name);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
internal static Horse DeserializeHorse(JsonElement element)
|
||||
{
|
||||
bool? isAShowHorse = default;
|
||||
string name = default;
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("isAShowHorse"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
isAShowHorse = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("name"))
|
||||
{
|
||||
name = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return new Horse(name, isAShowHorse);
|
||||
}
|
||||
}
|
||||
}
|
40
test/TestServerProjects/multiple-inheritance/Generated/Models/Horse.cs
сгенерированный
Normal file
40
test/TestServerProjects/multiple-inheritance/Generated/Models/Horse.cs
сгенерированный
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
|
||||
namespace multiple_inheritance.Models
|
||||
{
|
||||
/// <summary> The Horse. </summary>
|
||||
public partial class Horse : Pet
|
||||
{
|
||||
/// <summary> Initializes a new instance of Horse. </summary>
|
||||
/// <param name="name"> . </param>
|
||||
public Horse(string name) : base(name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of Horse. </summary>
|
||||
/// <param name="name"> . </param>
|
||||
/// <param name="isAShowHorse"> . </param>
|
||||
internal Horse(string name, bool? isAShowHorse) : base(name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
IsAShowHorse = isAShowHorse;
|
||||
}
|
||||
|
||||
public bool? IsAShowHorse { get; set; }
|
||||
}
|
||||
}
|
97
test/TestServerProjects/multiple-inheritance/Generated/Models/Kitten.Serialization.cs
сгенерированный
Normal file
97
test/TestServerProjects/multiple-inheritance/Generated/Models/Kitten.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,97 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace multiple_inheritance.Models
|
||||
{
|
||||
public partial class Kitten : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
if (EatsMiceYet != null)
|
||||
{
|
||||
writer.WritePropertyName("eatsMiceYet");
|
||||
writer.WriteBooleanValue(EatsMiceYet.Value);
|
||||
}
|
||||
if (LikesMilk != null)
|
||||
{
|
||||
writer.WritePropertyName("likesMilk");
|
||||
writer.WriteBooleanValue(LikesMilk.Value);
|
||||
}
|
||||
if (Meows != null)
|
||||
{
|
||||
writer.WritePropertyName("meows");
|
||||
writer.WriteBooleanValue(Meows.Value);
|
||||
}
|
||||
if (Hisses != null)
|
||||
{
|
||||
writer.WritePropertyName("hisses");
|
||||
writer.WriteBooleanValue(Hisses.Value);
|
||||
}
|
||||
writer.WritePropertyName("name");
|
||||
writer.WriteStringValue(Name);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
internal static Kitten DeserializeKitten(JsonElement element)
|
||||
{
|
||||
bool? eatsMiceYet = default;
|
||||
bool? likesMilk = default;
|
||||
bool? meows = default;
|
||||
bool? hisses = default;
|
||||
string name = default;
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("eatsMiceYet"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
eatsMiceYet = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("likesMilk"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
likesMilk = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("meows"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
meows = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("hisses"))
|
||||
{
|
||||
if (property.Value.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
hisses = property.Value.GetBoolean();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("name"))
|
||||
{
|
||||
name = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return new Kitten(name, likesMilk, meows, hisses, eatsMiceYet);
|
||||
}
|
||||
}
|
||||
}
|
43
test/TestServerProjects/multiple-inheritance/Generated/Models/Kitten.cs
сгенерированный
Normal file
43
test/TestServerProjects/multiple-inheritance/Generated/Models/Kitten.cs
сгенерированный
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
|
||||
namespace multiple_inheritance.Models
|
||||
{
|
||||
/// <summary> The Kitten. </summary>
|
||||
public partial class Kitten : Cat
|
||||
{
|
||||
/// <summary> Initializes a new instance of Kitten. </summary>
|
||||
/// <param name="name"> . </param>
|
||||
public Kitten(string name) : base(name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of Kitten. </summary>
|
||||
/// <param name="name"> . </param>
|
||||
/// <param name="likesMilk"> . </param>
|
||||
/// <param name="meows"> . </param>
|
||||
/// <param name="hisses"> . </param>
|
||||
/// <param name="eatsMiceYet"> . </param>
|
||||
internal Kitten(string name, bool? likesMilk, bool? meows, bool? hisses, bool? eatsMiceYet) : base(name, likesMilk, meows, hisses)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
EatsMiceYet = eatsMiceYet;
|
||||
}
|
||||
|
||||
public bool? EatsMiceYet { get; set; }
|
||||
}
|
||||
}
|
37
test/TestServerProjects/multiple-inheritance/Generated/Models/Pet.Serialization.cs
сгенерированный
Normal file
37
test/TestServerProjects/multiple-inheritance/Generated/Models/Pet.Serialization.cs
сгенерированный
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Text.Json;
|
||||
using Azure.Core;
|
||||
|
||||
namespace multiple_inheritance.Models
|
||||
{
|
||||
public partial class Pet : IUtf8JsonSerializable
|
||||
{
|
||||
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("name");
|
||||
writer.WriteStringValue(Name);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
internal static Pet DeserializePet(JsonElement element)
|
||||
{
|
||||
string name = default;
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("name"))
|
||||
{
|
||||
name = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return new Pet(name);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
|
||||
namespace multiple_inheritance.Models
|
||||
{
|
||||
/// <summary> The Pet. </summary>
|
||||
public partial class Pet
|
||||
{
|
||||
/// <summary> Initializes a new instance of Pet. </summary>
|
||||
/// <param name="name"> . </param>
|
||||
public Pet(string name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
}
|
||||
}
|
183
test/TestServerProjects/multiple-inheritance/Generated/Operations/ServiceClient.cs
сгенерированный
Normal file
183
test/TestServerProjects/multiple-inheritance/Generated/Operations/ServiceClient.cs
сгенерированный
Normal file
|
@ -0,0 +1,183 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Azure;
|
||||
using Azure.Core.Pipeline;
|
||||
using multiple_inheritance.Models;
|
||||
|
||||
namespace multiple_inheritance
|
||||
{
|
||||
public partial class ServiceClient
|
||||
{
|
||||
private readonly ClientDiagnostics _clientDiagnostics;
|
||||
private readonly HttpPipeline _pipeline;
|
||||
internal ServiceRestClient RestClient { get; }
|
||||
/// <summary> Initializes a new instance of ServiceClient for mocking. </summary>
|
||||
protected ServiceClient()
|
||||
{
|
||||
}
|
||||
/// <summary> Initializes a new instance of ServiceClient. </summary>
|
||||
internal ServiceClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string host = "http://localhost:3000")
|
||||
{
|
||||
RestClient = new ServiceRestClient(clientDiagnostics, pipeline, host);
|
||||
_clientDiagnostics = clientDiagnostics;
|
||||
_pipeline = pipeline;
|
||||
}
|
||||
|
||||
/// <summary> Get a horse with name 'Fred' and isAShowHorse true. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response<Horse>> GetHorseAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.GetHorseAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Get a horse with name 'Fred' and isAShowHorse true. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response<Horse> GetHorse(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.GetHorse(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Put a horse with name 'General' and isAShowHorse false. </summary>
|
||||
/// <param name="horse"> Put a horse with name 'General' and isAShowHorse false. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response<string>> PutHorseAsync(Horse horse, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PutHorseAsync(horse, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Put a horse with name 'General' and isAShowHorse false. </summary>
|
||||
/// <param name="horse"> Put a horse with name 'General' and isAShowHorse false. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response<string> PutHorse(Horse horse, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PutHorse(horse, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Get a pet with name 'Peanut'. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response<Pet>> GetPetAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.GetPetAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Get a pet with name 'Peanut'. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response<Pet> GetPet(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.GetPet(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Put a pet with name 'Butter'. </summary>
|
||||
/// <param name="pet"> Put a pet with name 'Butter'. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response<string>> PutPetAsync(Pet pet, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PutPetAsync(pet, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Put a pet with name 'Butter'. </summary>
|
||||
/// <param name="pet"> Put a pet with name 'Butter'. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response<string> PutPet(Pet pet, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PutPet(pet, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Get a feline where meows and hisses are true. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response<Feline>> GetFelineAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.GetFelineAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Get a feline where meows and hisses are true. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response<Feline> GetFeline(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.GetFeline(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Put a feline who hisses and doesn't meow. </summary>
|
||||
/// <param name="feline"> Put a feline who hisses and doesn't meow. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response<string>> PutFelineAsync(Feline feline, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PutFelineAsync(feline, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Put a feline who hisses and doesn't meow. </summary>
|
||||
/// <param name="feline"> Put a feline who hisses and doesn't meow. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response<string> PutFeline(Feline feline, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PutFeline(feline, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Get a cat with name 'Whiskers' where likesMilk, meows, and hisses is true. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response<Cat>> GetCatAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.GetCatAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Get a cat with name 'Whiskers' where likesMilk, meows, and hisses is true. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response<Cat> GetCat(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.GetCat(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. </summary>
|
||||
/// <param name="cat"> Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response<string>> PutCatAsync(Cat cat, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PutCatAsync(cat, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. </summary>
|
||||
/// <param name="cat"> Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response<string> PutCat(Cat cat, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PutCat(cat, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Get a kitten with name 'Gatito' where likesMilk and meows is true, and hisses and eatsMiceYet is false. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response<Kitten>> GetKittenAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.GetKittenAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Get a kitten with name 'Gatito' where likesMilk and meows is true, and hisses and eatsMiceYet is false. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response<Kitten> GetKitten(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.GetKitten(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary> Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is true. </summary>
|
||||
/// <param name="kitten"> Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is true. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual async Task<Response<string>> PutKittenAsync(Kitten kitten, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await RestClient.PutKittenAsync(kitten, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary> Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is true. </summary>
|
||||
/// <param name="kitten"> Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is true. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public virtual Response<string> PutKitten(Kitten kitten, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return RestClient.PutKitten(kitten, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
978
test/TestServerProjects/multiple-inheritance/Generated/Operations/ServiceRestClient.cs
сгенерированный
Normal file
978
test/TestServerProjects/multiple-inheritance/Generated/Operations/ServiceRestClient.cs
сгенерированный
Normal file
|
@ -0,0 +1,978 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Azure;
|
||||
using Azure.Core;
|
||||
using Azure.Core.Pipeline;
|
||||
using multiple_inheritance.Models;
|
||||
|
||||
namespace multiple_inheritance
|
||||
{
|
||||
internal partial class ServiceRestClient
|
||||
{
|
||||
private string host;
|
||||
private ClientDiagnostics _clientDiagnostics;
|
||||
private HttpPipeline _pipeline;
|
||||
|
||||
/// <summary> Initializes a new instance of ServiceRestClient. </summary>
|
||||
public ServiceRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string host = "http://localhost:3000")
|
||||
{
|
||||
if (host == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(host));
|
||||
}
|
||||
|
||||
this.host = host;
|
||||
_clientDiagnostics = clientDiagnostics;
|
||||
_pipeline = pipeline;
|
||||
}
|
||||
|
||||
internal HttpMessage CreateGetHorseRequest()
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Get;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/multipleInheritance/horse", false);
|
||||
request.Uri = uri;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Get a horse with name 'Fred' and isAShowHorse true. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response<Horse>> GetHorseAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.GetHorse");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetHorseRequest();
|
||||
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
Horse value = default;
|
||||
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Horse.DeserializeHorse(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Get a horse with name 'Fred' and isAShowHorse true. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response<Horse> GetHorse(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.GetHorse");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetHorseRequest();
|
||||
_pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
Horse value = default;
|
||||
using var document = JsonDocument.Parse(message.Response.ContentStream);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Horse.DeserializeHorse(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreatePutHorseRequest(Horse horse)
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Put;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/multipleInheritance/horse", false);
|
||||
request.Uri = uri;
|
||||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
content.JsonWriter.WriteObjectValue(horse);
|
||||
request.Content = content;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Put a horse with name 'General' and isAShowHorse false. </summary>
|
||||
/// <param name="horse"> Put a horse with name 'General' and isAShowHorse false. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response<string>> PutHorseAsync(Horse horse, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (horse == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(horse));
|
||||
}
|
||||
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.PutHorse");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutHorseRequest(horse);
|
||||
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
string value = default;
|
||||
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = document.RootElement.GetString();
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Put a horse with name 'General' and isAShowHorse false. </summary>
|
||||
/// <param name="horse"> Put a horse with name 'General' and isAShowHorse false. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response<string> PutHorse(Horse horse, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (horse == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(horse));
|
||||
}
|
||||
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.PutHorse");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutHorseRequest(horse);
|
||||
_pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
string value = default;
|
||||
using var document = JsonDocument.Parse(message.Response.ContentStream);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = document.RootElement.GetString();
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreateGetPetRequest()
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Get;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/multipleInheritance/pet", false);
|
||||
request.Uri = uri;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Get a pet with name 'Peanut'. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response<Pet>> GetPetAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.GetPet");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetPetRequest();
|
||||
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
Pet value = default;
|
||||
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Pet.DeserializePet(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Get a pet with name 'Peanut'. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response<Pet> GetPet(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.GetPet");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetPetRequest();
|
||||
_pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
Pet value = default;
|
||||
using var document = JsonDocument.Parse(message.Response.ContentStream);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Pet.DeserializePet(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreatePutPetRequest(Pet pet)
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Put;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/multipleInheritance/pet", false);
|
||||
request.Uri = uri;
|
||||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
content.JsonWriter.WriteObjectValue(pet);
|
||||
request.Content = content;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Put a pet with name 'Butter'. </summary>
|
||||
/// <param name="pet"> Put a pet with name 'Butter'. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response<string>> PutPetAsync(Pet pet, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (pet == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(pet));
|
||||
}
|
||||
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.PutPet");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutPetRequest(pet);
|
||||
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
string value = default;
|
||||
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = document.RootElement.GetString();
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Put a pet with name 'Butter'. </summary>
|
||||
/// <param name="pet"> Put a pet with name 'Butter'. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response<string> PutPet(Pet pet, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (pet == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(pet));
|
||||
}
|
||||
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.PutPet");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutPetRequest(pet);
|
||||
_pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
string value = default;
|
||||
using var document = JsonDocument.Parse(message.Response.ContentStream);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = document.RootElement.GetString();
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreateGetFelineRequest()
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Get;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/multipleInheritance/feline", false);
|
||||
request.Uri = uri;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Get a feline where meows and hisses are true. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response<Feline>> GetFelineAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.GetFeline");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetFelineRequest();
|
||||
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
Feline value = default;
|
||||
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Feline.DeserializeFeline(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Get a feline where meows and hisses are true. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response<Feline> GetFeline(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.GetFeline");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetFelineRequest();
|
||||
_pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
Feline value = default;
|
||||
using var document = JsonDocument.Parse(message.Response.ContentStream);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Feline.DeserializeFeline(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreatePutFelineRequest(Feline feline)
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Put;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/multipleInheritance/feline", false);
|
||||
request.Uri = uri;
|
||||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
content.JsonWriter.WriteObjectValue(feline);
|
||||
request.Content = content;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Put a feline who hisses and doesn't meow. </summary>
|
||||
/// <param name="feline"> Put a feline who hisses and doesn't meow. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response<string>> PutFelineAsync(Feline feline, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (feline == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(feline));
|
||||
}
|
||||
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.PutFeline");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutFelineRequest(feline);
|
||||
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
string value = default;
|
||||
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = document.RootElement.GetString();
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Put a feline who hisses and doesn't meow. </summary>
|
||||
/// <param name="feline"> Put a feline who hisses and doesn't meow. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response<string> PutFeline(Feline feline, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (feline == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(feline));
|
||||
}
|
||||
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.PutFeline");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutFelineRequest(feline);
|
||||
_pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
string value = default;
|
||||
using var document = JsonDocument.Parse(message.Response.ContentStream);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = document.RootElement.GetString();
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreateGetCatRequest()
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Get;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/multipleInheritance/cat", false);
|
||||
request.Uri = uri;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Get a cat with name 'Whiskers' where likesMilk, meows, and hisses is true. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response<Cat>> GetCatAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.GetCat");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetCatRequest();
|
||||
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
Cat value = default;
|
||||
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Cat.DeserializeCat(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Get a cat with name 'Whiskers' where likesMilk, meows, and hisses is true. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response<Cat> GetCat(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.GetCat");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetCatRequest();
|
||||
_pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
Cat value = default;
|
||||
using var document = JsonDocument.Parse(message.Response.ContentStream);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Cat.DeserializeCat(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreatePutCatRequest(Cat cat)
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Put;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/multipleInheritance/cat", false);
|
||||
request.Uri = uri;
|
||||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
content.JsonWriter.WriteObjectValue(cat);
|
||||
request.Content = content;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. </summary>
|
||||
/// <param name="cat"> Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response<string>> PutCatAsync(Cat cat, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (cat == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(cat));
|
||||
}
|
||||
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.PutCat");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutCatRequest(cat);
|
||||
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
string value = default;
|
||||
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = document.RootElement.GetString();
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. </summary>
|
||||
/// <param name="cat"> Put a cat with name 'Boots' where likesMilk and hisses is false, meows is true. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response<string> PutCat(Cat cat, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (cat == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(cat));
|
||||
}
|
||||
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.PutCat");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutCatRequest(cat);
|
||||
_pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
string value = default;
|
||||
using var document = JsonDocument.Parse(message.Response.ContentStream);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = document.RootElement.GetString();
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreateGetKittenRequest()
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Get;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/multipleInheritance/kitten", false);
|
||||
request.Uri = uri;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Get a kitten with name 'Gatito' where likesMilk and meows is true, and hisses and eatsMiceYet is false. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response<Kitten>> GetKittenAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.GetKitten");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetKittenRequest();
|
||||
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
Kitten value = default;
|
||||
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Kitten.DeserializeKitten(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Get a kitten with name 'Gatito' where likesMilk and meows is true, and hisses and eatsMiceYet is false. </summary>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response<Kitten> GetKitten(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.GetKitten");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreateGetKittenRequest();
|
||||
_pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
Kitten value = default;
|
||||
using var document = JsonDocument.Parse(message.Response.ContentStream);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Kitten.DeserializeKitten(document.RootElement);
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal HttpMessage CreatePutKittenRequest(Kitten kitten)
|
||||
{
|
||||
var message = _pipeline.CreateMessage();
|
||||
var request = message.Request;
|
||||
request.Method = RequestMethod.Put;
|
||||
var uri = new RawRequestUriBuilder();
|
||||
uri.AppendRaw(host, false);
|
||||
uri.AppendPath("/multipleInheritance/kitten", false);
|
||||
request.Uri = uri;
|
||||
request.Headers.Add("Content-Type", "application/json");
|
||||
using var content = new Utf8JsonRequestContent();
|
||||
content.JsonWriter.WriteObjectValue(kitten);
|
||||
request.Content = content;
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary> Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is true. </summary>
|
||||
/// <param name="kitten"> Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is true. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public async ValueTask<Response<string>> PutKittenAsync(Kitten kitten, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (kitten == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(kitten));
|
||||
}
|
||||
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.PutKitten");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutKittenRequest(kitten);
|
||||
await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
string value = default;
|
||||
using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = document.RootElement.GetString();
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is true. </summary>
|
||||
/// <param name="kitten"> Put a kitten with name 'Kitty' where likesMilk and hisses is false, meows and eatsMiceYet is true. </param>
|
||||
/// <param name="cancellationToken"> The cancellation token to use. </param>
|
||||
public Response<string> PutKitten(Kitten kitten, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (kitten == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(kitten));
|
||||
}
|
||||
|
||||
using var scope = _clientDiagnostics.CreateScope("ServiceClient.PutKitten");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
using var message = CreatePutKittenRequest(kitten);
|
||||
_pipeline.Send(message, cancellationToken);
|
||||
switch (message.Response.Status)
|
||||
{
|
||||
case 200:
|
||||
{
|
||||
string value = default;
|
||||
using var document = JsonDocument.Parse(message.Response.ContentStream);
|
||||
if (document.RootElement.ValueKind == JsonValueKind.Null)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = document.RootElement.GetString();
|
||||
}
|
||||
return Response.FromValue(value, message.Response);
|
||||
}
|
||||
default:
|
||||
throw _clientDiagnostics.CreateRequestFailedException(message.Response);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Nullable>annotations</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Azure.Core" Version="1.1.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="4.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Загрузка…
Ссылка в новой задаче