Skip to content

Commit

Permalink
Process swagger file cross reference when generating API review (#7438)
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenkuttappan authored Dec 12, 2023
1 parent f55acff commit 8240399
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
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() && !response.@ref.StartsWith("#"))
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 (schema.@ref.StartsWith("#") && !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

0 comments on commit 8240399

Please sign in to comment.