mirror of
https://github.com/ysoftdevs/wapifuzz.git
synced 2026-03-24 02:11:13 +01:00
Merge branch 'added_base_bath'
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using Models;
|
using Models;
|
||||||
|
|
||||||
@@ -12,19 +14,33 @@ namespace Parser
|
|||||||
|
|
||||||
foreach (var path in openApiDocument.Paths)
|
foreach (var path in openApiDocument.Paths)
|
||||||
{
|
{
|
||||||
endpoints.Add(ParseEndpoint(path));
|
endpoints.Add(ParseEndpoint(path, GetBasePath(openApiDocument)));
|
||||||
}
|
}
|
||||||
return endpoints;
|
return endpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Endpoint ParseEndpoint(KeyValuePair<string, OpenApiPathItem> path)
|
static Endpoint ParseEndpoint(KeyValuePair<string, OpenApiPathItem> path, string basePath)
|
||||||
{
|
{
|
||||||
Endpoint endpoint = new Endpoint(path.Key);
|
Endpoint endpoint = new Endpoint(basePath + path.Key);
|
||||||
foreach (KeyValuePair<OperationType, OpenApiOperation> operation in path.Value.Operations)
|
foreach (KeyValuePair<OperationType, OpenApiOperation> operation in path.Value.Operations)
|
||||||
{
|
{
|
||||||
endpoint.Requests.Add(RequestParser.ParseRequest(operation));
|
endpoint.Requests.Add(RequestParser.ParseRequest(operation));
|
||||||
}
|
}
|
||||||
return endpoint;
|
return endpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string GetBasePath(OpenApiDocument openApiDocument)
|
||||||
|
{
|
||||||
|
string basePath = string.Empty;
|
||||||
|
if (openApiDocument.Servers.Any())
|
||||||
|
{
|
||||||
|
basePath = new Uri(openApiDocument.Servers.First().Url).AbsolutePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (basePath == "/")
|
||||||
|
basePath = string.Empty;
|
||||||
|
|
||||||
|
return basePath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ info:
|
|||||||
license:
|
license:
|
||||||
name: MIT
|
name: MIT
|
||||||
servers:
|
servers:
|
||||||
- url: http://petstore.swagger.io/v1
|
- url: http://petstore.swagger.io
|
||||||
paths:
|
paths:
|
||||||
/pets?attributeName={attributeValue}:
|
/pets?attributeName={attributeValue}:
|
||||||
get:
|
get:
|
||||||
|
|||||||
Reference in New Issue
Block a user