Files
wapifuzz/parser/Parser/EndpointParser.cs
2019-10-09 13:24:35 +02:00

31 lines
889 B
C#

using System.Collections.Generic;
using Microsoft.OpenApi.Models;
using Models;
namespace Parser
{
public static class EndpointParser
{
public static List<Endpoint> ParseAllEndpoints(OpenApiDocument openApiDocument)
{
List<Endpoint> endpoints = new List<Endpoint>();
foreach (var path in openApiDocument.Paths)
{
endpoints.Add(ParseEndpoint(path));
}
return endpoints;
}
static Endpoint ParseEndpoint(KeyValuePair<string, OpenApiPathItem> path)
{
Endpoint endpoint = new Endpoint(path.Key);
foreach (KeyValuePair<OperationType, OpenApiOperation> operation in path.Value.Operations)
{
endpoint.Requests.Add(RequestParser.ParseRequest(operation));
}
return endpoint;
}
}
}