Ejemplo n.º 1
0
        private IParameter CreateParameter(
            ApiDescription apiDescription,
            ApiParameterDescription paramDescription,
            ISchemaRegistry schemaRegistry)
        {
            var location = GetParameterLocation(apiDescription, paramDescription);

            var name = _settings.DescribeAllParametersInCamelCase
                ? paramDescription.Name.ToCamelCase()
                : paramDescription.Name;

            var schema = (paramDescription.Type == null) ? null : schemaRegistry.GetOrRegister(paramDescription.Type);

            if (location == "body")
            {
                return(new BodyParameter
                {
                    Name = name,
                    Schema = schema
                });
            }

            var nonBodyParam = new NonBodyParameter
            {
                Name     = name,
                In       = location,
                Required = (location == "path")
            };

            if (schema == null)
            {
                nonBodyParam.Type = "string";
            }
            else
            {
                nonBodyParam.PopulateFrom(schema);
            }

            if (nonBodyParam.Type == "array")
            {
                nonBodyParam.CollectionFormat = "multi";
            }

            return(nonBodyParam);
        }
Ejemplo n.º 2
0
        private IParameter CreateParameter(ApiParameterDescription paramDesc, ISchemaRegistry schemaRegistry)
        {
            var source = paramDesc.Source.Id.ToLower();
            var schema = (paramDesc.Type == null) ? null : schemaRegistry.GetOrRegister(paramDesc.Type);

            if (source == "body")
            {
                return(new BodyParameter
                {
                    Name = paramDesc.Name,
                    In = source,
                    Schema = schema
                });
            }
            else
            {
                var nonBodyParam = new NonBodyParameter
                {
                    Name     = paramDesc.Name,
                    In       = source,
                    Required = (source == "path")
                };

                if (schema == null)
                {
                    nonBodyParam.Type = "string";
                }
                else
                {
                    nonBodyParam.PopulateFrom(schema);
                }

                if (nonBodyParam.Type == "array")
                {
                    nonBodyParam.CollectionFormat = "multi";
                }

                return(nonBodyParam);
            }
        }
Ejemplo n.º 3
0
        private IParameter CreateParameter(ApiParameterDescription paramDesc, ISchemaRegistry schemaRegistry)
        {
            var source = paramDesc.Source.Id.ToLower();
            var schema = (paramDesc.Type == null) ? null : schemaRegistry.GetOrRegister(paramDesc.Type);

            if (source == "body")
            {
                return new BodyParameter
                {
                    Name = paramDesc.Name,
                    In = source,
                    Schema = schema
                };
            }
            else
            {
                var nonBodyParam = new NonBodyParameter
                {
                    Name = paramDesc.Name,
                    In = source,
                    Required = (source == "path")
                };

                if (schema == null)
                    nonBodyParam.Type = "string";
                else
                    nonBodyParam.PopulateFrom(schema);

                if (nonBodyParam.Type == "array")
                    nonBodyParam.CollectionFormat = "multi";

                return nonBodyParam;
            }
        }