private static Parameter BuildParameter(OperationParameter p, SchemaResolutionContext resolutionContext) { return(new Parameter { Name = p.Name, IsRequired = p.IsRequired, Schema = p.Schema?.ResolveSchema(resolutionContext), Description = p.Description, Type = p.Type, Deprecated = p.Deprecated, AllowEmptyValue = p.AllowEmptyValue, Enum = p.Enum, ExclusiveMaximum = p.ExclusiveMaximum, ExclusiveMinimum = p.ExclusiveMinimum, MaxItems = p.MaxItems, MaxLength = p.MaxLength, MaxProperties = p.MaxProperties, Maximum = p.Maximum, MinItems = p.MinItems, MinLength = p.MinLength, MinProperties = p.MinProperties, Minimum = p.Minimum, MultipleOf = p.MultipleOf, Pattern = p.Pattern, Title = p.Title, UniqueItems = p.UniqueItems }); }
public abstract Schema ResolveSchema(SchemaResolutionContext resolutionContext);
private static Response BuildResponse(KeyValuePair <string, OperationResponse> responseKvp, SchemaResolutionContext resolutionContext) { return(new Response { Code = responseKvp.Key, Description = responseKvp.Value.Description, Schema = responseKvp.Value.Schema?.ResolveSchema(resolutionContext) }); }
private static IEnumerable <EndpointInfo> BuildEndpointEntry(KeyValuePair <string, Dictionary <string, Operation> > path, SchemaResolutionContext schemaResolutionContext) { Logger.Info($"Processing endpoint: {path.Key}"); return(path.Value.Select(httpMethod => new EndpointInfo { EndpointPath = path.Key, HttpMethod = httpMethod.Key.ToUpper(), Deprecated = httpMethod.Value.Deprecated, Summary = httpMethod.Value.Summary, QueryParameter = httpMethod.Value.OperationParameters?.Where(x => x.In == "query") .Select(parameter => BuildParameter(parameter, schemaResolutionContext)) .ToList(), BodyParameters = httpMethod.Value.OperationParameters?.Where(x => x.In == "body") .Select(parameter => BuildParameter(parameter, schemaResolutionContext)) .ToList(), FormDataParameters = httpMethod.Value.OperationParameters?.Where(x => x.In == "formData") .Select(parameter => BuildParameter(parameter, schemaResolutionContext)) .ToList(), PathParameters = httpMethod.Value.OperationParameters?.Where(x => x.In == "path") .Select(parameter => BuildParameter(parameter, schemaResolutionContext)) .ToList(), Responses = httpMethod.Value.Responses? .Select(response => BuildResponse(response, schemaResolutionContext)) .ToList() })); }