Example #1
0
 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
     });
 }
Example #2
0
 public abstract Schema ResolveSchema(SchemaResolutionContext resolutionContext);
Example #3
0
 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)
     });
 }
Example #4
0
 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()
     }));
 }