Skip to content

Commit

Permalink
Merge pull request #1369 from SimonCropp/remove-some-redundant-braces
Browse files Browse the repository at this point in the history
remove some redundant braces
  • Loading branch information
MaggieKimani1 authored Oct 2, 2023
2 parents 7857663 + 4b341a0 commit a847203
Show file tree
Hide file tree
Showing 61 changed files with 578 additions and 552 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private void AddAdditionalPropertiesToSchema(OpenApiSchema schema)
{
if (schema != null && !_schemaLoop.Contains(schema) && "object".Equals(schema.Type, StringComparison.OrdinalIgnoreCase))
{
schema.AdditionalProperties = new OpenApiSchema() { Type = "object" };
schema.AdditionalProperties = new OpenApiSchema { Type = "object" };

/* Because 'additionalProperties' are now being walked,
* we need a way to keep track of visited schemas to avoid
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi.Hidi/OpenApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private static void WriteOpenApi(HidiOptions options, OpenApiFormat openApiForma
using var outputStream = options.Output.Create();
using var textWriter = new StreamWriter(outputStream);

var settings = new OpenApiWriterSettings()
var settings = new OpenApiWriterSettings
{
InlineLocalReferences = options.InlineLocal,
InlineExternalReferences = options.InlineExternal
Expand Down Expand Up @@ -738,7 +738,7 @@ internal static async Task PluginManifest(HidiOptions options, ILogger logger, C
WriteOpenApi(options, OpenApiFormat.Json, OpenApiSpecVersion.OpenApi3_0, document, logger);

// Create OpenAIPluginManifest from ApiDependency and OpenAPI document
var manifest = new OpenAIPluginManifest()
var manifest = new OpenAIPluginManifest
{
NameForHuman = document.Info.Title,
DescriptionForHuman = document.Info.Description,
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi.Hidi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static async Task<int> Main(string[] args)

internal static RootCommand CreateRootCommand()
{
var rootCommand = new RootCommand() { };
var rootCommand = new RootCommand { };

var commandOptions = new CommandOptions();

Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public async Task<ReadResult> ReadAsync(YamlDocument input, CancellationToken ca
}
}

return new ReadResult()
return new ReadResult
{
OpenApiDocument = document,
OpenApiDiagnostic = diagnostic
Expand All @@ -148,7 +148,7 @@ private async Task<OpenApiDiagnostic> LoadExternalRefs(OpenApiDocument document,
// Load this root document into the workspace
var streamLoader = new DefaultStreamLoader(_settings.BaseUrl);
var workspaceLoader = new OpenApiWorkspaceLoader(openApiWorkSpace, _settings.CustomExternalLoader ?? streamLoader, _settings);
return await workspaceLoader.LoadAsync(new OpenApiReference() { ExternalResource = "/" }, document, cancellationToken);
return await workspaceLoader.LoadAsync(new OpenApiReference { ExternalResource = "/" }, document, cancellationToken);
}

private void ResolveReferences(OpenApiDiagnostic diagnostic, OpenApiDocument document)
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi.Readers/ParseNodes/MapNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public override Dictionary<string, T> CreateMapWithReference<T>(
// If the component isn't a reference to another component, then point it to itself.
if (entry.value.Reference == null)
{
entry.value.Reference = new OpenApiReference()
entry.value.Reference = new OpenApiReference
{
Type = referenceType,
Id = entry.key
Expand Down Expand Up @@ -184,7 +184,7 @@ public override string GetRaw()
public T GetReferencedObject<T>(ReferenceType referenceType, string referenceId)
where T : IOpenApiReferenceable, new()
{
return new T()
return new T
{
UnresolvedReference = true,
Reference = Context.VersionService.ConvertToOpenApiReference(referenceId, referenceType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private static string BuildUrl(string scheme, string host, string basePath)
port = int.Parse(pieces.Last(), CultureInfo.InvariantCulture);
}

var uriBuilder = new UriBuilder()
var uriBuilder = new UriBuilder
{
Scheme = scheme,
Host = host,
Expand Down Expand Up @@ -327,10 +327,10 @@ public override void Visit(OpenApiOperation operation)
if (body != null)
{
operation.Parameters.Remove(body);
operation.RequestBody = new OpenApiRequestBody()
operation.RequestBody = new OpenApiRequestBody
{
UnresolvedReference = true,
Reference = new OpenApiReference()
Reference = new OpenApiReference
{
Id = body.Reference.Id,
Type = ReferenceType.RequestBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ private static OpenApiTag LoadTagByReference(
ParsingContext context,
string tagName)
{
var tagObject = new OpenApiTag()
var tagObject = new OpenApiTag
{
UnresolvedReference = true,
Reference = new OpenApiReference() { Id = tagName, Type = ReferenceType.Tag }
Reference = new OpenApiReference { Id = tagName, Type = ReferenceType.Tag }
};

return tagObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal static partial class OpenApiV2Deserializer
{
"$ref", (o, n) =>
{
o.Reference = new OpenApiReference() { ExternalResource = n.GetScalarValue() };
o.Reference = new OpenApiReference { ExternalResource = n.GetScalarValue() };
o.UnresolvedReference =true;
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ private static OpenApiSecurityScheme LoadSecuritySchemeByReference(
ParsingContext context,
string schemeName)
{
var securitySchemeObject = new OpenApiSecurityScheme()
var securitySchemeObject = new OpenApiSecurityScheme
{
UnresolvedReference = true,
Reference = new OpenApiReference()
Reference = new OpenApiReference
{
Id = schemeName,
Type = ReferenceType.SecurityScheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal static partial class OpenApiV3Deserializer
{"tags", (o, n) => {o.Tags = n.CreateList(LoadTag);
foreach (var tag in o.Tags)
{
tag.Reference = new OpenApiReference()
tag.Reference = new OpenApiReference
{
Id = tag.Name,
Type = ReferenceType.Tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ private static OpenApiTag LoadTagByReference(
ParsingContext context,
string tagName)
{
var tagObject = new OpenApiTag()
var tagObject = new OpenApiTag
{
UnresolvedReference = true,
Reference = new OpenApiReference()
Reference = new OpenApiReference
{
Type = ReferenceType.Tag,
Id = tagName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal static partial class OpenApiV3Deserializer

{
"$ref", (o,n) => {
o.Reference = new OpenApiReference() { ExternalResource = n.GetScalarValue() };
o.Reference = new OpenApiReference { ExternalResource = n.GetScalarValue() };
o.UnresolvedReference =true;
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public static OpenApiSchema LoadSchema(ParseNode node)

if (pointer != null)
{
return new OpenApiSchema()
return new OpenApiSchema
{
UnresolvedReference = true,
Reference = node.Context.VersionService.ConvertToOpenApiReference(pointer, ReferenceType.Schema)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ private static OpenApiSecurityScheme LoadSecuritySchemeByReference(
ParsingContext context,
string schemeName)
{
var securitySchemeObject = new OpenApiSecurityScheme()
var securitySchemeObject = new OpenApiSecurityScheme
{
UnresolvedReference = true,
Reference = new OpenApiReference()
Reference = new OpenApiReference
{
Id = schemeName,
Type = ReferenceType.SecurityScheme
Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.OpenApi.Workbench/MainModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ private string WriteContents(OpenApiDocument document)
outputStream,
Version,
Format,
new OpenApiWriterSettings() {
new OpenApiWriterSettings
{
InlineLocalReferences = InlineLocal,
InlineExternalReferences = InlineExternal
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
public static OpenApiPrimaryErrorMessageExtension Parse(IOpenApiAny source)
{
if (source is not OpenApiBoolean rawObject) throw new ArgumentOutOfRangeException(nameof(source));
return new OpenApiPrimaryErrorMessageExtension() {
return new OpenApiPrimaryErrorMessageExtension
{
IsPrimaryErrorMessage = rawObject.Value
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private void ResolveTags(IList<OpenApiTag> tags)

if (resolvedTag == null)
{
resolvedTag = new OpenApiTag()
resolvedTag = new OpenApiTag
{
Name = tag.Reference.Id
};
Expand Down Expand Up @@ -291,7 +291,7 @@ private void ResolveTags(IList<OpenApiTag> tags)
else
{
// Leave as unresolved reference
return new T()
return new T
{
UnresolvedReference = true,
Reference = reference
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Services/OperationSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override void Visit(OpenApiPathItem pathItem)

if (_predicate(CurrentKeys.Path, operationType, operation))
{
_searchResults.Add(new SearchResult()
_searchResults.Add(new SearchResult
{
Operation = operation,
Parameters = pathItem.Parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ public class PowerShellFormatterTests
public void FormatOperationIdsInOpenAPIDocument(string operationId, string expectedOperationId, OperationType operationType, string path = "/foo")
{
// Arrange
var openApiDocument = new OpenApiDocument()
var openApiDocument = new OpenApiDocument
{
Info = new() { Title = "Test", Version = "1.0" },
Servers = new List<OpenApiServer>() { new() { Url = "https://localhost/" } },
Servers = new List<OpenApiServer> { new() { Url = "https://localhost/" } },
Paths = new()
{
{ path, new() {
Operations = new Dictionary<OperationType, OpenApiOperation>() {
Operations = new Dictionary<OperationType, OpenApiOperation>
{
{ operationType, new() { OperationId = operationId } }
}
}
Expand Down Expand Up @@ -92,22 +93,22 @@ public void ResolveFunctionParameters()

private static OpenApiDocument GetSampleOpenApiDocument()
{
return new OpenApiDocument()
return new OpenApiDocument
{
Info = new() { Title = "Test", Version = "1.0" },
Servers = new List<OpenApiServer>() { new() { Url = "https://localhost/" } },
Servers = new List<OpenApiServer> { new() { Url = "https://localhost/" } },
Paths = new() {
{ "/foo", new()
{
Operations = new Dictionary<OperationType, OpenApiOperation>()
Operations = new Dictionary<OperationType, OpenApiOperation>
{
{
OperationType.Get, new()
{
OperationId = "Foo.GetFoo",
Parameters = new List<OpenApiParameter>
{
new OpenApiParameter()
new OpenApiParameter
{
Name = "ids",
In = ParameterLocation.Query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@ public void ReturnFilteredOpenApiDocumentBasedOnPostmanCollection()
[Fact]
public void TestPredicateFiltersUsingRelativeRequestUrls()
{
var openApiDocument = new OpenApiDocument()
var openApiDocument = new OpenApiDocument
{
Info = new() { Title = "Test", Version = "1.0" },
Servers = new List<OpenApiServer>() { new() { Url = "https://localhost/" } },
Servers = new List<OpenApiServer> { new() { Url = "https://localhost/" } },
Paths = new()
{
{"/foo", new() {
Operations = new Dictionary<OperationType, OpenApiOperation>() {
Operations = new Dictionary<OperationType, OpenApiOperation>
{
{ OperationType.Get, new() },
{ OperationType.Patch, new() },
{ OperationType.Post, new() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram()
{

// create a dummy ILogger instance for testing
var options = new HidiOptions()
var options = new HidiOptions
{
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
Output = new FileInfo("sample.md")
Expand All @@ -151,7 +151,7 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagram()
[Fact]
public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagram()
{
var options = new HidiOptions()
var options = new HidiOptions
{
OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml")
};
Expand All @@ -162,7 +162,7 @@ public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagram()
[Fact]
public async Task ShowCommandGeneratesMermaidMarkdownFileFromCsdlWithMermaidDiagram()
{
var options = new HidiOptions()
var options = new HidiOptions
{
Csdl = Path.Combine("UtilityFiles", "Todo.xml"),
CsdlFilter = "todos",
Expand Down
Loading

0 comments on commit a847203

Please sign in to comment.