:
[Route("/warranties", "POST", Summary = "POST New Warrantty", Notes = "Create new warranty into our system")]
public class CreateWarrantyRequest : IReturn<ApiResponse>
{
[ApiMember(Name = "CoverageId", Description = "Coverage Id", DataType = "int", IsRequired = true)]
public string CoverageId { get; set; }
[ApiMember(Name = "WarrantyProducts", Description = "Warranty Products", DataType = "List<WarrantyProduct>", IsRequired = true)]
public List<WarrantyProduct> WarrantyProducts { get; set; }
}
public class WarrantyProduct
{
[ApiMember(Name = "Manufacturer", Description = "Manufacturer Name", DataType = "string", IsRequired = true)]
public string Manufacturer { get; set; }
[ApiMember(Name = "ProductType ", Description = "Product Type", DataType = "ProductType", IsRequired = true)]
public ProductType ProductType { get; set; }
[ApiMember(Name = "SerialNumber", Description = "Serial Number", DataType = "string", IsRequired = true)]
public string SerialNumber { get; set; }
[ApiMember(Name = "PurchasePrice", Description = "Purchase Price", DataType = "decimal", IsRequired = true)]
public decimal PurchasePrice { get; set; }
}
そして、これはそれがSwaggerFeatureでどのように見えるかです:: ![enter image description here](https://i.stack.imgur.com/5Nh8I.png)
そして、これはそれがOpenApiFeatureでどのように見えるかです
EDIT はここでフルDTOサンプルですDataTypeはa known typeを指定するためのものです。 List<T>
のような複雑な型の定義は、そのitems
referencing the Complex Type schema、例えばとarray
タイプを指定することによって行われます。
{
"description": "A complex object array response",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/VeryComplexType"
}
}
}
これはServiceStackは、データ型を指定せずに自動的に何をするかで、複合型を定義することはできません[ApiMember]
を使用します。
SwaggerFeatureを使用するとき、私は要求のためのモデルスキーマを持っていますが、OpenApiFeatureを使用しているときは表示されません。また、OpenApiFeatureを使用しているときはデータ型に "未定義"が表示されます。あなたはこれについていくつかのC#の例を表示できますか、多分何か間違っていますか? – ShP
@ShP Swagger UIの2つの異なるバージョンを使用して消費される2つの異なる仕様です。私が言ったように、属性を使って複雑な型を定義する方法はありませんが、ServiceStackはOpen API仕様に従って適切な複合型定義を既に出しています。 – mythz
私はちょっと混乱していますが、あなたはSSがすでに適切な複合型を発行していると言っていますが、オブジェクトのOpenApiでは "未定義"と書かれています。 – ShP