Exemple #1
0
        public StatisticsMetadataModule(ISwaggerModelCatalog modelCatalog, ISwaggerTagCatalog tagCatalog)
            : base(modelCatalog, tagCatalog)
        {
            SwaggerTypeMapping.AddTypeMapping(typeof(DateTime), typeof(DateTime));

            RouteDescriber.AddBaseTag(new Tag
            {
                Description = "Operations for getting projection statistics",
                Name        = "Statistics"
            });

            RouteDescriber.DescribeRoute <IEnumerable <ProjectorSummary> >("GetAll", "",
                                                                           "Returns a list of all known projectors and a summary of their status", new[]
            {
                new HttpResponseMetadata {
                    Code = 200, Message = "OK"
                }
            });

            RouteDescriber
            .DescribeRoute <ProjectorDetails>("GetSpecific", "", "Returns the details of a specific projector", new[]
            {
                new HttpResponseMetadata {
                    Code = 200, Message = "OK"
                }
            })
            .Parameter(p => p.Name("id").In(ParameterIn.Path).Description("Identifies the projector"));


            RouteDescriber
            .DescribeRoute <ProjectorEventCollection>("GetEvents", "", "Returns the events logged for a specific projector", new[]
            {
                new HttpResponseMetadata {
                    Code = 200, Message = "OK"
                }
            })
            .Parameter(p => p.Name("id").In(ParameterIn.Path).Description("Identifies the projector"));;

            RouteDescriber
            .DescribeRoute <string>("GetEta", "", "Returns the ETA for a specific projector to reach a certain checkpoint", new[]
            {
                new HttpResponseMetadata {
                    Code = 200, Message = "OK"
                }
            })
            .Parameter(p => p.Name("id").In(ParameterIn.Path).Description("Identifies the projector"))
            .Parameter(p => p.Name("targetCheckpoint").In(ParameterIn.Path).Description("The target checkpoint for which to calculate the ETA"));

            RouteDescriber.AddAdditionalModels(
                typeof(ProjectorEvent), typeof(ProjectorProperty), typeof(ProjectorSummary));
        }
Exemple #2
0
        public ServiceDetailsMetadataModule(ISwaggerModelCatalog modelCatalog, ISwaggerTagCatalog tagCatalog) : base(modelCatalog, tagCatalog)
        {
            RouteDescriber.AddBaseTag(new Tag()
            {
                Description = "Operations for handling the service",
                Name        = "Service"
            });

            var customerSubTag = new Tag()
            {
                Name        = "Service/Customers",
                Description = "Operations of 'Service' relating to Customers"
            };

            RouteDescriber.DescribeRoute("ServiceHome", "", "Get Home", new[]
            {
                new HttpResponseMetadata {
                    Code = 200, Message = "OK"
                }
            });

            RouteDescriber.AddAdditionalModels(typeof(ServiceOwner), typeof(ServiceCustomer));
            RouteDescriber.DescribeRoute <ServiceDetails>("GetDetails", "", "Get Details", new[]
            {
                new HttpResponseMetadata {
                    Code = 200, Message = "OK"
                }
            });

            RouteDescriber.DescribeRoute <IEnumerable <ServiceCustomer> >("GetCustomers", "", "Get Customers", new[]
            {
                new HttpResponseMetadata {
                    Code = 200, Message = "OK"
                }
            }, new[]
            {
                customerSubTag
            });

            RouteDescriber.DescribeRouteWithParams("GetCustomer", "", "Get Customer", new HttpResponseMetadata[]
            {
                new HttpResponseMetadata <ServiceCustomer> {
                    Code = 200, Message = "OK"
                },
                new HttpResponseMetadata <IEnumerable <ServiceCustomer> > {
                    Code = 202, Message = "Multiple Customers Found"
                },
                new HttpResponseMetadata {
                    Code = 404, Message = "No Customers Found"
                },
            }, new[]
            {
                new Parameter {
                    Name = "name", In = ParameterIn.Path, Required = true, Description = "The customer's name", Default = "Jack", Type = "string"
                }
            }, new[]
            {
                customerSubTag
            });

            RouteDescriber.DescribeRouteWithParams <ServiceCustomer>("PostNewCustomer", "", "Add a new customer", new[]
            {
                new HttpResponseMetadata {
                    Code = 200, Message = "Customer Added"
                },
            }, new[]
            {
                new Parameter {
                    Name = "service", In = ParameterIn.Path, Required = true, Description = "The service's name", Default = "Nancy Swagger Service", Type = "string"
                },
                new BodyParameter <ServiceCustomer>(ModelCatalog)
                {
                    Name = "user", Required = true, Description = "The user"
                },
            }, new []
            {
                customerSubTag
            });

            RouteDescriber.DescribeRouteWithParams <SwaggerFile>("PostCustomerReview", "", "Add a customer's review", new[]
            {
                new HttpResponseMetadata <SwaggerFile> {
                    Code = 200, Message = "Review Added"
                },
            }, new[]
            {
                new Parameter {
                    Name = "name", In = ParameterIn.Path, Required = true, Description = "The customer's name", Default = "Jill", Type = "string"
                },
                new Parameter {
                    Name = "file", In = ParameterIn.Form, Required = true, Description = "The customer's review", Type = "file"
                },
            }, new[]
            {
                customerSubTag
            })
            //If you need to add something that is not a parameter to DescribeRoute,
            //the function will return the OperationBuilder so you can add it.
            .ProduceMimeTypes(new[] { "multipart/form-data", "application/x-www-form-urlencoded" });
        }
        public ConfigurationNancyMetadataModule(
            ISwaggerModelCatalog modelCatalog,
            ISwaggerTagCatalog tagCatalog)
            : base(modelCatalog, tagCatalog)
        {
            var configurationStoreTag = new Tag
            {
                Name        = "Configuration",
                Description = "Operations to manage configuration values"
            };

            RouteDescriber
            .AddAdditionalModels(typeof(Nav));
            RouteDescriber
            .AddAdditionalModels(typeof(ConfigKeyListItem));
            RouteDescriber
            .AddAdditionalModels(typeof(ValueType));

            RouteDescriber.DescribeRoute <IEnumerable <ConfigKeyListItem> >(
                RouteRegistry.Api.Configuration.GetConfigs.Name,
                "Gets a summary of all configuration keys available",
                "Gets a summary of all configuration keys available",
                new[]
            {
                new HttpResponseMetadata <IEnumerable <ConfigKeyListItem> >
                {
                    Code    = (int)HttpStatusCode.OK,
                    Message = "OK"
                }
            },
                new[]
            {
                configurationStoreTag
            });

            RouteDescriber.DescribeRouteWithParams <ConfigValueListItem>(
                RouteRegistry.Api.Configuration.GetConfigForVersion.Name,
                "Gets the latest configuration value for the environment tag specified in the defined version",
                "Gets configuration value for environment",
                new[]
            {
                new HttpResponseMetadata <ConfigValueListItem>
                {
                    Code    = (int)HttpStatusCode.OK,
                    Message = "OK"
                },
                new HttpResponseMetadata
                {
                    Code    = (int)HttpStatusCode.NotFound,
                    Message = "Configuration key or value for environment not found"
                },
                new HttpResponseMetadata
                {
                    Code    = (int)HttpStatusCode.NotModified,
                    Message = "Configuration value found for environment, but no change from client version"
                }
            },
                new[]
            {
                new Parameter
                {
                    Name        = "configKey",
                    In          = ParameterIn.Path,
                    Required    = true,
                    Description = "The configuration's key",
                    Type        = "string"
                },
                new Parameter
                {
                    Name        = "configVersion:version",
                    In          = ParameterIn.Path,
                    Required    = true,
                    Description = "The configuration's value version (semantic version format)",
                    Type        = "string"
                },
                new Parameter
                {
                    Name        = "envTag",
                    In          = ParameterIn.Path,
                    Required    = true,
                    Description = "The configuration's environment",
                    Type        = "string"
                },
                new Parameter
                {
                    Name        = "seq",
                    In          = ParameterIn.Query,
                    Required    = false,
                    Description = "Current sequence value held by client",
                    Type        = "integer"
                }
            },
                new[]
            {
                configurationStoreTag
            });

            RouteDescriber.DescribeRouteWithParams(
                RouteRegistry.Api.Configuration.AddNewConfiguration.Name,
                "Adds a new configuration key with a given value type",
                "Add a new configuration key",
                new[]
            {
                new HttpResponseMetadata
                {
                    Code    = (int)HttpStatusCode.OK,
                    Message = "OK"
                },
                new HttpResponseMetadata
                {
                    Code    = (int)HttpStatusCode.BadRequest,
                    Message = "Request received does not match expectation"
                }
            },
                new[]
            {
                new Parameter
                {
                    Name        = "configKey",
                    In          = ParameterIn.Path,
                    Required    = true,
                    Description = "The configuration's key",
                    Type        = "string"
                },
                new BodyParameter <NewConfigurationRequest>(modelCatalog)
                {
                    Name        = "new configuration",
                    Required    = true,
                    Description = "The configuration definition"
                }
            },
                new[]
            {
                configurationStoreTag
            });

            RouteDescriber.DescribeRouteWithParams(
                RouteRegistry.Api.Configuration.AddNewValueToConfiguration.Name,
                "Adds a new configuration value to an existing key, used to add values to a different set of environments",
                "Add a new configuration value for the key",
                new[]
            {
                new HttpResponseMetadata
                {
                    Code    = (int)HttpStatusCode.OK,
                    Message = "OK"
                },
                new HttpResponseMetadata
                {
                    Code    = (int)HttpStatusCode.BadRequest,
                    Message = "Request received does not match expectation"
                }
            },
                new[]
            {
                new Parameter
                {
                    Name        = "configKey",
                    In          = ParameterIn.Path,
                    Required    = true,
                    Description = "The configuration key",
                    Type        = "string"
                },
                new Parameter
                {
                    Name        = "configVersion:version",
                    In          = ParameterIn.Path,
                    Required    = true,
                    Description = "The configuration key's version",
                    Type        = "string"
                },
                new BodyParameter <NewValueToConfigurationRequest>(modelCatalog)
                {
                    Name        = "new configuration value",
                    Required    = true,
                    Description = "The configuration value definition"
                }
            },
                new[]
            {
                configurationStoreTag
            });

            RouteDescriber.DescribeRouteWithParams(
                RouteRegistry.Api.Configuration.UpdateValueOnConfiguration.Name,
                "Updates a specific configuration value, bumping the sequence number",
                "Updates a configuration value",
                new[]
            {
                new HttpResponseMetadata
                {
                    Code    = (int)HttpStatusCode.OK,
                    Message = "OK"
                },
                new HttpResponseMetadata
                {
                    Code    = (int)HttpStatusCode.BadRequest,
                    Message = "Request received does not match expectation"
                }
            },
                new[]
            {
                new Parameter
                {
                    Name        = "configKey",
                    In          = ParameterIn.Path,
                    Required    = true,
                    Description = "The configuration key",
                    Type        = "string"
                },
                new Parameter
                {
                    Name        = "configVersion:version",
                    In          = ParameterIn.Path,
                    Required    = true,
                    Description = "The configuration key's version",
                    Type        = "string"
                },
                new Parameter
                {
                    Name        = "valueId:guid",
                    In          = ParameterIn.Path,
                    Required    = true,
                    Description = "The configuration value's identifier",
                    Type        = "string"
                },
                new BodyParameter <UpdateValueOnConfigurationRequest>(modelCatalog)
                {
                    Name        = "new configuration value",
                    Required    = true,
                    Description = "The configuration value definition"
                }
            },
                new[]
            {
                configurationStoreTag
            });

            RouteDescriber.DescribeRouteWithParams(
                RouteRegistry.Api.Configuration.DeleteConfiguration.Name,
                "Deletes a specific configuration key, with all versions and all their values",
                "Deletes a configuration key",
                new[]
            {
                new HttpResponseMetadata
                {
                    Code    = (int)HttpStatusCode.OK,
                    Message = "Deleted configuration key"
                },
            },
                new[]
            {
                new Parameter
                {
                    Name        = "configKey",
                    In          = ParameterIn.Path,
                    Required    = true,
                    Description = "The configuration key",
                    Type        = "string"
                }
            },
                new[]
            {
                configurationStoreTag
            });

            RouteDescriber.DescribeRouteWithParams(
                RouteRegistry.Api.Configuration.DeleteValueFromConfiguration.Name,
                "Deletes a specific configuration value for a key with a specific version",
                "Deletes a configuration key",
                new[]
            {
                new HttpResponseMetadata
                {
                    Code    = (int)HttpStatusCode.OK,
                    Message = "Deleted configuration key"
                },
            },
                new[]
            {
                new Parameter
                {
                    Name        = "configKey",
                    In          = ParameterIn.Path,
                    Required    = true,
                    Description = "The configuration key",
                    Type        = "string"
                },
                new Parameter
                {
                    Name        = "configVersion:version",
                    In          = ParameterIn.Path,
                    Required    = true,
                    Description = "The configuration key's version",
                    Type        = "string"
                },
                new Parameter
                {
                    Name        = "valueId:guid",
                    In          = ParameterIn.Path,
                    Required    = true,
                    Description = "The configuration value's identifier",
                    Type        = "string"
                }
            },
                new[]
            {
                configurationStoreTag
            });
        }