Skip to content

Commit a4519b4

Browse files
committed
Updated hidi parameters to control both local and remote inlining independently
1 parent 971d827 commit a4519b4

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/Microsoft.OpenApi.Hidi/OpenApiService.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ public static void ProcessOpenApiDocument(
2626
FileInfo output,
2727
OpenApiSpecVersion? version,
2828
OpenApiFormat? format,
29+
bool inlineExternal,
30+
bool inlineLocal,
2931
string filterByOperationIds,
3032
string filterByTags,
31-
string filterByCollection,
32-
bool inline,
33-
bool resolveExternal)
33+
string filterByCollection
34+
)
3435
{
3536
if (string.IsNullOrEmpty(input))
3637
{
@@ -52,7 +53,7 @@ public static void ProcessOpenApiDocument(
5253

5354
var result = new OpenApiStreamReader(new OpenApiReaderSettings
5455
{
55-
ReferenceResolution = resolveExternal == true ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences,
56+
ReferenceResolution = inlineExternal == true ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences,
5657
RuleSet = ValidationRuleSet.GetDefaultRuleSet(),
5758
BaseUrl = new Uri(inputUrl.AbsoluteUri)
5859
}
@@ -105,7 +106,8 @@ public static void ProcessOpenApiDocument(
105106

106107
var settings = new OpenApiWriterSettings()
107108
{
108-
ReferenceInline = inline ? ReferenceInlineSetting.InlineLocalReferences : ReferenceInlineSetting.DoNotInlineReferences
109+
InlineLocalReferences = inlineLocal,
110+
InlineExternalReferences = inlineExternal
109111
};
110112

111113
var openApiFormat = format ?? GetOpenApiFormat(input);

src/Microsoft.OpenApi.Hidi/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ static async Task<int> Main(string[] args)
2828
new Option("--output","Output OpenAPI description file", typeof(FileInfo), arity: ArgumentArity.ZeroOrOne),
2929
new Option("--version", "OpenAPI specification version", typeof(OpenApiSpecVersion)),
3030
new Option("--format", "File format",typeof(OpenApiFormat) ),
31-
new Option("--inline", "Inline $ref instances", typeof(bool) ),
32-
new Option("--resolveExternal","Resolve external $refs", typeof(bool)),
31+
new Option("--inlineExternal", "Inline external $ref instances", typeof(bool) ),
32+
new Option("--inlineLocal", "Inline local $ref instances", typeof(bool) ),
3333
new Option("--filterByOperationIds", "Filters OpenApiDocument by OperationId(s) provided", typeof(string)),
3434
new Option("--filterByTags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)),
3535
new Option("--filterByCollection", "Filters OpenApiDocument by Postman collection provided", typeof(string))
3636
};
37-
transformCommand.Handler = CommandHandler.Create<string, FileInfo, OpenApiSpecVersion?, OpenApiFormat?, string, string, string, bool, bool>(
37+
transformCommand.Handler = CommandHandler.Create<string, FileInfo, OpenApiSpecVersion?, OpenApiFormat?, bool, bool, string, string, string>(
3838
OpenApiService.ProcessOpenApiDocument);
3939

4040
rootCommand.Add(transformCommand);

src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public enum ReferenceResolutionSetting
3030
/// </summary>
3131
ResolveLocalReferences,
3232
/// <summary>
33-
/// Convert all references to references of valid domain objects.
33+
/// Not used anymore. Will be removed in v2. Convert all references to references of valid domain objects.
3434
/// </summary>
3535
ResolveAllReferences
3636
}

0 commit comments

Comments
 (0)