diff --git a/src/OpenApi/OpenApiGenerator_Document.cs b/src/OpenApi/OpenApiGenerator_Document.cs index 9f60ebb01..611910890 100644 --- a/src/OpenApi/OpenApiGenerator_Document.cs +++ b/src/OpenApi/OpenApiGenerator_Document.cs @@ -189,10 +189,6 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) }, {"/OData.svc/content({id})/$metadata", new PathItem { - Parameters = new[] - { - new Parameter { Ref = Ref.Parameters + Ref.P.IdInPath }, - }, Get = new Operation { Tags = new []{ "Metadata" }, @@ -203,6 +199,7 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) OperationId = "sn_v1_get_metadata_of_entity_by_id", Parameters = new [] { + new Parameter { Ref = Ref.Parameters + Ref.P.IdInPath }, new Parameter{Ref = Ref.Parameters + Ref.P.Metadata_format}, }, Responses = new Dictionary @@ -216,10 +213,6 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) }, {"/OData.svc/{_path}/$metadata", new PathItem { - Parameters = new[] - { - new Parameter { Ref = Ref.Parameters + Ref.P.EntitySetPath } - }, Get = new Operation { Tags = new []{ "Metadata" }, @@ -230,6 +223,7 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) OperationId = "sn_v1_get_metadata_of_collection", Parameters = new [] { + new Parameter { Ref = Ref.Parameters + Ref.P.EntitySetPath }, new Parameter{Ref = Ref.Parameters + Ref.P.Metadata_format}, }, Responses = new Dictionary @@ -243,11 +237,6 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) }, {"/OData.svc/{_path}('{_name}')/$metadata", new PathItem { - Parameters = new[] - { - new Parameter { Ref = Ref.Parameters + Ref.P.EntitySetPath }, - new Parameter { Ref = Ref.Parameters + Ref.P.EntityName } - }, Get = new Operation { Tags = new []{ "Metadata" }, @@ -258,6 +247,8 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) OperationId = "sn_v1_get_metadata_of_entity_by_path", Parameters = new [] { + new Parameter { Ref = Ref.Parameters + Ref.P.EntitySetPath }, + new Parameter { Ref = Ref.Parameters + Ref.P.EntityName }, new Parameter{Ref = Ref.Parameters + Ref.P.Metadata_format}, }, Responses = new Dictionary @@ -271,10 +262,6 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) }, {"/OData.svc/{_path}", new PathItem { - Parameters = new[] - { - new Parameter { Ref = Ref.Parameters + Ref.P.EntitySetPath } - }, Get = new Operation { Tags = new []{ "Basic-Collection" }, @@ -283,6 +270,7 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) OperationId = "sn_v1_get_children", Parameters = new [] { + new Parameter { Ref = Ref.Parameters + Ref.P.EntitySetPath }, new Parameter{Ref = Ref.Parameters + Ref.P.Metadata}, new Parameter{Ref = Ref.Parameters + Ref.P.Top}, new Parameter{Ref = Ref.Parameters + Ref.P.Skip}, @@ -318,16 +306,16 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) }, {"/OData.svc/{_path}/$count", new PathItem { - Parameters = new[] - { - new Parameter { Ref = Ref.Parameters + Ref.P.EntitySetPath } - }, Get = new Operation { Tags = new []{ "Basic-Collection" }, Summary = "Returns count of children.", Description = "Returns count of child elements under the {_path}.", OperationId = "sn_v1_get_children_count", + Parameters = new[] + { + new Parameter { Ref = Ref.Parameters + Ref.P.EntitySetPath }, + }, Responses = new Dictionary { {"403", new Response{Ref = Ref.Responses + Ref.R.Http403}}, @@ -347,10 +335,6 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) }, {"/OData.svc/content({id})", new PathItem { - Parameters = new[] - { - new Parameter { Ref = Ref.Parameters + Ref.P.IdInPath }, - }, Get = new Operation { Tags = new []{ "Basic-Entity" }, @@ -359,6 +343,7 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) OperationId = "sn_v1_get_entity_by_id", Parameters = new [] { + new Parameter { Ref = Ref.Parameters + Ref.P.IdInPath }, new Parameter{Ref = Ref.Parameters + Ref.P.Metadata}, new Parameter{Ref = Ref.Parameters + Ref.P.Expand}, new Parameter{Ref = Ref.Parameters + Ref.P.Select}, @@ -392,6 +377,7 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) OperationId = "sn_v1_create_content_under_entity_by_id", Parameters = new [] { + new Parameter { Ref = Ref.Parameters + Ref.P.IdInPath }, new Parameter{Ref = Ref.Parameters + Ref.P.Metadata}, new Parameter{Ref = Ref.Parameters + Ref.P.Expand}, new Parameter{Ref = Ref.Parameters + Ref.P.Select}, @@ -438,6 +424,7 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) OperationId = "sn_v1_reset_content_by_id", Parameters = new [] { + new Parameter { Ref = Ref.Parameters + Ref.P.IdInPath }, new Parameter{Ref = Ref.Parameters + Ref.P.Metadata}, new Parameter{Ref = Ref.Parameters + Ref.P.Expand}, new Parameter{Ref = Ref.Parameters + Ref.P.Select}, @@ -483,6 +470,7 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) OperationId = "sn_v1_patch_content_by_id", Parameters = new [] { + new Parameter { Ref = Ref.Parameters + Ref.P.IdInPath }, new Parameter{Ref = Ref.Parameters + Ref.P.Metadata}, new Parameter{Ref = Ref.Parameters + Ref.P.Expand}, new Parameter{Ref = Ref.Parameters + Ref.P.Select}, @@ -526,8 +514,9 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) Summary = "Deletes the content.", Description = "The content will be deleted or trashed.", OperationId = "sn_v1_delete_entity_by_id", - Parameters = new Parameter[] + Parameters = new [] { + new Parameter { Ref = Ref.Parameters + Ref.P.IdInPath }, new Parameter { Name = "permanent", @@ -546,25 +535,25 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) }, {"/OData.svc/content({id})/{property}", new PathItem { - Parameters = new[] - { - new Parameter { Ref = Ref.Parameters + Ref.P.IdInPath }, - new Parameter - { - Name = "property", - In = "path", - Required = true, - AllowEmptyValue = false, - Description = "Name of the requested property.", - Schema = new ObjectSchema {Type = T.String} - }, - }, Get = new Operation { Tags = new []{ "Basic-Entity" }, Summary = "Gets a property of the given Content.", Description = "Returns the requested property of the given Content", OperationId = "sn_v1_get_property_by_id", + Parameters = new[] + { + new Parameter { Ref = Ref.Parameters + Ref.P.IdInPath }, + new Parameter + { + Name = "property", + In = "path", + Required = true, + AllowEmptyValue = false, + Description = "Name of the requested property.", + Schema = new ObjectSchema {Type = T.String} + }, + }, Responses = new Dictionary { {"403", new Response{Ref = Ref.Responses + Ref.R.Http403}}, @@ -576,25 +565,25 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) }, {"/OData.svc/content({id})/{property}/$value", new PathItem { - Parameters = new[] - { - new Parameter { Ref = Ref.Parameters + Ref.P.IdInPath }, - new Parameter - { - Name = "property", - In = "path", - Required = true, - AllowEmptyValue = false, - Description = "Name of the requested property.", - Schema = new ObjectSchema {Type = T.String} - }, - }, Get = new Operation { Tags = new []{ "Basic-Entity" }, Summary = "Gets a property value of the given Content.", Description = "Returns the requested property value of the given Content", OperationId = "sn_v1_get_property_value_by_id", + Parameters = new[] + { + new Parameter { Ref = Ref.Parameters + Ref.P.IdInPath }, + new Parameter + { + Name = "property", + In = "path", + Required = true, + AllowEmptyValue = false, + Description = "Name of the requested property.", + Schema = new ObjectSchema {Type = T.String} + }, + }, Responses = new Dictionary { {"403", new Response{Ref = Ref.Responses + Ref.R.Http403}}, @@ -612,13 +601,90 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) }, } }, - {"/OData.svc/{_path}('{_name}')", new PathItem + {"/OData.svc/('Root')", new PathItem { - Parameters = new[] + Get = new Operation + { + Tags = new []{ "Basic-Entity" }, + Summary = "Gets the Root content.", + /*TODO*/Description = "Returns the requested Content if it is permitted for the current user. The collection of properties depends from the Content's ContentType and the value of the '$select' parameter.", + OperationId = "sn_v1_get_entity_by_path", + Parameters = new [] + { + new Parameter{Ref = Ref.Parameters + Ref.P.Metadata}, + new Parameter{Ref = Ref.Parameters + Ref.P.Expand}, + new Parameter{Ref = Ref.Parameters + Ref.P.Select}, + new Parameter{Ref = Ref.Parameters + Ref.P.Format}, + new Parameter{Ref = Ref.Parameters + Ref.P.Version}, + }, + Responses = new Dictionary + { + {"403", new Response{Ref = Ref.Responses + Ref.R.Http403}}, + {"404", new Response{Ref = Ref.Responses + Ref.R.Http404}}, + {"200", new Response + { + Description = "Payload.", + Content = new Dictionary + { + {"application/json", new MediaType + { + Schema = new ObjectSchema{ Ref = Ref.Schemas + Ref.S.ODataEntity } + } + } + } + } + } + } + }, + Post = new Operation { - new Parameter { Ref = Ref.Parameters + Ref.P.EntityParentPath }, - new Parameter { Ref = Ref.Parameters + Ref.P.EntityName } + Tags = new []{ "Basic-Entity" }, + Summary = "Creates a new child content.", + Description = "???", + OperationId = "sn_v1_create_content_under_entity_by_path", + Parameters = new [] + { + new Parameter{Ref = Ref.Parameters + Ref.P.Metadata}, + new Parameter{Ref = Ref.Parameters + Ref.P.Expand}, + new Parameter{Ref = Ref.Parameters + Ref.P.Select}, + new Parameter{Ref = Ref.Parameters + Ref.P.Format}, + }, + RequestBody = new RequestBody + { + Description = "Data for creation. Only the `__ContentType` is required. After creation, the unspecified properties are assigned their default values.", + Required = true, + Content = new Dictionary + { + {"application/json", new MediaType + { + Schema = new ObjectSchema{Ref = Ref.Schemas + Ref.S.ContentCreationRequest} + } + } + } + }, + Responses = new Dictionary + { + {"403", new Response{Ref = Ref.Responses + Ref.R.Http403_creation}}, + {"404", new Response{Ref = Ref.Responses + Ref.R.Http404_creation}}, + {"200", new Response + { + Description = "The newly created content according to the given parameters (metadata, $expand, $select, $format).", + Content = new Dictionary + { + {"application/json", new MediaType + { + Schema = new ObjectSchema{ Ref = Ref.Schemas + Ref.S.ODataEntity } + } + } + } + } + } + } }, + } + }, + {"/OData.svc/{_path}('{_name}')", new PathItem + { Get = new Operation { Tags = new []{ "Basic-Entity" }, @@ -627,6 +693,8 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) OperationId = "sn_v1_get_entity_by_path", Parameters = new [] { + new Parameter { Ref = Ref.Parameters + Ref.P.EntityParentPath }, + new Parameter { Ref = Ref.Parameters + Ref.P.EntityName }, new Parameter{Ref = Ref.Parameters + Ref.P.Metadata}, new Parameter{Ref = Ref.Parameters + Ref.P.Expand}, new Parameter{Ref = Ref.Parameters + Ref.P.Select}, @@ -660,6 +728,8 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) OperationId = "sn_v1_create_content_under_entity_by_path", Parameters = new [] { + new Parameter { Ref = Ref.Parameters + Ref.P.EntityParentPath }, + new Parameter { Ref = Ref.Parameters + Ref.P.EntityName }, new Parameter{Ref = Ref.Parameters + Ref.P.Metadata}, new Parameter{Ref = Ref.Parameters + Ref.P.Expand}, new Parameter{Ref = Ref.Parameters + Ref.P.Select}, @@ -667,7 +737,7 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) }, RequestBody = new RequestBody { - Description = "???", + Description = "Data for creation. Only the `__ContentType` is required. After creation, the unspecified properties are assigned their default values.", Required = true, Content = new Dictionary { @@ -706,6 +776,8 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) OperationId = "sn_v1_reset_content_by_path", Parameters = new [] { + new Parameter { Ref = Ref.Parameters + Ref.P.EntityParentPath }, + new Parameter { Ref = Ref.Parameters + Ref.P.EntityName }, new Parameter{Ref = Ref.Parameters + Ref.P.Metadata}, new Parameter{Ref = Ref.Parameters + Ref.P.Expand}, new Parameter{Ref = Ref.Parameters + Ref.P.Select}, @@ -751,6 +823,8 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) OperationId = "sn_v1_patch_content_by_path", Parameters = new [] { + new Parameter { Ref = Ref.Parameters + Ref.P.EntityParentPath }, + new Parameter { Ref = Ref.Parameters + Ref.P.EntityName }, new Parameter{Ref = Ref.Parameters + Ref.P.Metadata}, new Parameter{Ref = Ref.Parameters + Ref.P.Expand}, new Parameter{Ref = Ref.Parameters + Ref.P.Select}, @@ -796,6 +870,8 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) OperationId = "sn_v1_delete_entity_by_path", Parameters = new Parameter[] { + new Parameter { Ref = Ref.Parameters + Ref.P.EntityParentPath }, + new Parameter { Ref = Ref.Parameters + Ref.P.EntityName }, new Parameter { Name = "permanent", @@ -814,26 +890,26 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) }, {"/OData.svc/{_path}('{_name}')/{property}", new PathItem { - Parameters = new[] - { - new Parameter { Ref = Ref.Parameters + Ref.P.EntityParentPath }, - new Parameter { Ref = Ref.Parameters + Ref.P.EntityName }, - new Parameter - { - Name = "property", - In = "path", - Required = true, - AllowEmptyValue = false, - Description = "Name of the requested property.", - Schema = new ObjectSchema {Type = T.String} - }, - }, Get = new Operation { Tags = new []{ "Basic-Entity" }, Summary = "Gets a property of the given Content.", Description = "Returns the requested property of the given Content", OperationId = "sn_v1_get_property_by_path", + Parameters = new[] + { + new Parameter { Ref = Ref.Parameters + Ref.P.EntityParentPath }, + new Parameter { Ref = Ref.Parameters + Ref.P.EntityName }, + new Parameter + { + Name = "property", + In = "path", + Required = true, + AllowEmptyValue = false, + Description = "Name of the requested property.", + Schema = new ObjectSchema {Type = T.String} + }, + }, Responses = new Dictionary { {"403", new Response{Ref = Ref.Responses + Ref.R.Http403}}, @@ -845,26 +921,26 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) }, {"/OData.svc/{_path}('{_name}')/{property}/$value", new PathItem { - Parameters = new[] - { - new Parameter { Ref = Ref.Parameters + Ref.P.EntityParentPath }, - new Parameter { Ref = Ref.Parameters + Ref.P.EntityName }, - new Parameter - { - Name = "property", - In = "path", - Required = true, - AllowEmptyValue = false, - Description = "Name of the requested property.", - Schema = new ObjectSchema {Type = T.String} - }, - }, Get = new Operation { Tags = new []{ "Basic-Entity" }, Summary = "Gets a property value of the given Content.", Description = "Returns the requested property value of the given Content. The property should be exist otherwise the response will be `UnknownAction` error.", OperationId = "sn_v1_get_property_value_by_path", + Parameters = new[] + { + new Parameter { Ref = Ref.Parameters + Ref.P.EntityParentPath }, + new Parameter { Ref = Ref.Parameters + Ref.P.EntityName }, + new Parameter + { + Name = "property", + In = "path", + Required = true, + AllowEmptyValue = false, + Description = "Name of the requested property.", + Schema = new ObjectSchema {Type = T.String} + }, + }, Responses = new Dictionary { {"403", new Response{Ref = Ref.Responses + Ref.R.Http403}}, @@ -919,7 +995,7 @@ public static OpenApiDocument CreateOpenApiDocument(string thisUrl) Name = "_path", In = "path", Required = true, - AllowEmptyValue = true, + AllowEmptyValue = false, Description = "Path of the container content. Leading slash is omitted. If empty, the {name} should be 'Root'.", Schema = new ObjectSchema { Type = T.String } }