Пример #1
0
        public static OpenApiOperation CreatePatchOperationForSingleton(this IEdmSingleton singleton)
        {
            OpenApiOperation operation = new OpenApiOperation
            {
                Summary = "Update " + singleton.Name,
                Tags    = new List <string>
                {
                    singleton.Name
                }
            };

            operation.RequestBody = new OpenApiRequestBody
            {
                Required    = true,
                Description = "New property values",
                Content     = new Dictionary <string, OpenApiMediaType>
                {
                    {
                        "application/json", new OpenApiMediaType
                        {
                            Schema = new OpenApiSchema
                            {
                                Reference = new OpenApiReference("#/components/schemas/" + singleton.EntityType().FullName())
                            }
                        }
                    }
                }
            };

            operation.Responses = new OpenApiResponses
            {
                "204".GetResponse(),
                "default".GetResponse()
            };
            return(operation);
        }
Пример #2
0
        public static OpenApiOperation CreateGetOperationForEntitySet(this IEdmEntitySet entitySet)
        {
            OpenApiOperation operation = new OpenApiOperation
            {
                Summary = "Get entities from " + entitySet.Name,
                Tags    = new List <string>
                {
                    entitySet.Name
                }
            };

            operation.Parameters = new List <OpenApiParameter>
            {
                new OpenApiParameter
                {
                    Reference = new OpenApiReference("#/components/parameters/top")
                },
                new OpenApiParameter
                {
                    Reference = new OpenApiReference("#/components/parameters/skip")
                },
                new OpenApiParameter
                {
                    Reference = new OpenApiReference("#/components/parameters/search")
                },
                new OpenApiParameter
                {
                    Reference = new OpenApiReference("#/components/parameters/filter")
                },
                new OpenApiParameter
                {
                    Reference = new OpenApiReference("#/components/parameters/count")
                },

                CreateOrderByParameter(entitySet),

                CreateSelectParameter(entitySet),

                CreateExpandParameter(entitySet),
            };

            operation.Responses = new OpenApiResponses
            {
                {
                    "200",
                    new OpenApiResponse
                    {
                        Description = "Retrieved entities",
                        Content     = new Dictionary <string, OpenApiMediaType>
                        {
                            {
                                "application/json",
                                new OpenApiMediaType
                                {
                                    Schema = new OpenApiSchema
                                    {
                                        Title      = "Collection of " + entitySet.Name,
                                        Type       = "object",
                                        Properties = new Dictionary <string, OpenApiSchema>
                                        {
                                            {
                                                "value",
                                                new OpenApiSchema
                                                {
                                                    Type  = "array",
                                                    Items = new OpenApiSchema
                                                    {
                                                        Reference = new OpenApiReference("#/components/schemas/" + entitySet.EntityType().FullName())
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            operation.Responses.Add("default".GetResponse());

            return(operation);
        }