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

Order swagger input files #5574

Merged
merged 1 commit into from
Feb 28, 2023
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
Expand Up @@ -54,8 +54,8 @@ public static IEnumerable<string> GetSwaggerFilesFromReadme(string readme, strin
readmeTag = parser.basicConfig.tag;
}

parser.inputSwaggerFilesMap.TryGetValue(readmeTag, out InputSwaggerFiles ret);
return ret != null ? ret.input : new List<string>();
parser.inputSwaggerFilesMap.TryGetValue(readmeTag, out InputSwaggerFiles inputFiles);
return inputFiles?.input ?? Enumerable.Empty<string>();
}
private void ParseReadmeConfig()
{
Expand Down Expand Up @@ -93,6 +93,8 @@ private void ParseReadmeConfig()
}

var tag = ReadmeParser.GetTagFromYamlArguments(argument);

inputSwaggerFiles.input?.Sort(StringComparer.InvariantCultureIgnoreCase);
inputSwaggerFilesMap.Add(tag, inputSwaggerFiles);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,12 @@ public void TestGetTagFromYamlArgumentsInvalidCase()
Assert.Equal("", result);

}

[Fact]
public void TestOrderedInputFiles()
{
const string readmeFilePath = "./fixtures/unordered.md";
var inputFiles = ReadmeParser.GetSwaggerFilesFromReadme(readmeFilePath, "package-2023-02");
Assert.Collection(inputFiles, x => Assert.Equal("a.json", x), x => Assert.Equal("z.json", x));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
<ItemGroup>
<Content Include="fixtures/**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<None Remove="fixtures\unordered.md" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Unordered

> see https://aka.ms/autorest

This is the AutoRest configuration file for Unordered.

---

## Getting Started

To build the SDK for ApiManagement, simply [Install AutoRest](https://aka.ms/autorest/install) and in this folder, run:

> `autorest`

To see additional help and options, run:

> `autorest --help`

---

## Configuration

### Basic Information

These are the global settings for the ApiManagement API.

``` yaml
title: UnorderedClient
description: Unordered Client
tag: package-2023-02
```


### Tag: package-2023-02

These settings apply only when `--tag=package-2023-02` is specified on the command line.

```yaml $(tag) == 'package-2023-02'
input-file:
- z.json
- a.json
```