Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process swagger file cross reference when generating API review #7438

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release History

## 1.3.0 (12-12-2023)
+ Support local schema reference in another referred swagger file

## 1.2.0 (11-29-2023)
+ Added API version as PackageVersion in code file.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,22 @@ public static async Task<SwaggerApiViewSpec> GenerateSwaggerApiView(Swagger swag
{
var resp = response;
var referenceSwaggerFilePath = swaggerFilePath;
string referencePath = "";

if (response.IsRefObject())
{
resp = (Response)swaggerSpec.ResolveRefObj(response.@ref);
if (resp == null)
{
resp = (Response)schemaCache.GetResponseFromCache(response.@ref, swaggerFilePath);
// Update reference path if referenced object is in another swagger file
if (response.IsRefObject() && [email protected]("#"))
referencePath = response.@ref;
}

if (resp == null)
{
var referencePath = response.@ref;
referencePath = response.@ref;
do
{
if (!Path.IsPathFullyQualified(referencePath))
Expand Down Expand Up @@ -216,7 +220,13 @@ public static async Task<SwaggerApiViewSpec> GenerateSwaggerApiView(Swagger swag
{
if (schema.IsRefObject())
{
var referencePath = schema.@ref;
// Update swagger file path to correct file if schema reference is local but parent itself is in another swagger file
if ([email protected]("#") && !string.IsNullOrEmpty(referencePath))
{
referenceSwaggerFilePath = Utils.GetReferencedSwaggerFile(referencePath, referenceSwaggerFilePath);
}

referencePath = schema.@ref;
do
{
referenceSwaggerFilePath = Utils.GetReferencedSwaggerFile(referencePath, referenceSwaggerFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ToolCommandName>swaggerAPIParser</ToolCommandName>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>SwaggerApiParser</RootNamespace>
<VersionPrefix>1.2.0</VersionPrefix>
<VersionPrefix>1.3.0</VersionPrefix>
<AssemblyName>Azure.Sdk.Tools.SwaggerApiParser</AssemblyName>
<SignAssembly>True</SignAssembly>
<InformationalVersion>$(OfficialBuildId)</InformationalVersion>
Expand Down