Skip to content

chore: flatten namespace hierarchy #2368

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

Merged
merged 4 commits into from
May 27, 2025
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions performance/benchmark/Descriptions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Reflection;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using Microsoft.OpenApi;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Reader;

namespace performance;
Expand Down
6 changes: 2 additions & 4 deletions performance/benchmark/EmptyModels.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using BenchmarkDotNet;
using BenchmarkDotNet.Attributes;
using Microsoft.OpenApi.Models;
using BenchmarkDotNet.Attributes;
using Microsoft.OpenApi;

namespace performance;
[MemoryDiagnoser]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Text.Json.Nodes;

namespace Microsoft.OpenApi.Hidi.Extensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
using Humanizer;
using Humanizer.Inflections;
using Microsoft.OpenApi.Hidi.Extensions;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.Interfaces;
using Microsoft.OpenApi.Services;

namespace Microsoft.OpenApi.Hidi.Formatters
{
Expand Down
9 changes: 2 additions & 7 deletions src/Microsoft.OpenApi.Hidi/OpenApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,11 @@
using Microsoft.OpenApi.ApiManifest;
using Microsoft.OpenApi.ApiManifest.OpenAI;
using Microsoft.OpenApi.ApiManifest.OpenAI.Authentication;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Hidi.Extensions;
using Microsoft.OpenApi.Hidi.Formatters;
using Microsoft.OpenApi.Hidi.Options;
using Microsoft.OpenApi.Hidi.Utilities;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.OData;
using Microsoft.OpenApi.Reader;
using Microsoft.OpenApi.Services;
using Microsoft.OpenApi.Writers;
using Microsoft.OpenApi.YamlReader;
using static Microsoft.OpenApi.Hidi.OpenApiSpecVersionHelper;

namespace Microsoft.OpenApi.Hidi
Expand Down Expand Up @@ -420,7 +414,8 @@ private static async Task<ReadResult> ParseOpenApiAsync(string openApiFile, bool
var edmModel = CsdlReader.Parse(XElement.Parse(csdlText).CreateReader());
settings ??= SettingsUtilities.GetConfiguration();

var document = edmModel.ConvertToOpenApi(SettingsUtilities.GetOpenApiConvertSettings(settings, metadataVersion));
// TODO: uncomment when namespaces are fixed in OData lib
var document = new OpenApiDocument(); //edmModel.ConvertToOpenApi(SettingsUtilities.GetOpenApiConvertSettings(settings, metadataVersion));
document = FixReferences(document, format);

return document;
Expand Down
3 changes: 0 additions & 3 deletions src/Microsoft.OpenApi.Hidi/StatsVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

using System;
using System.Collections.Generic;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.Interfaces;
using Microsoft.OpenApi.Services;

namespace Microsoft.OpenApi.Hidi
{
Expand Down
6 changes: 0 additions & 6 deletions src/Microsoft.OpenApi.Workbench/MainModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Reader;
using Microsoft.OpenApi.Services;
using Microsoft.OpenApi.Validations;
using Microsoft.OpenApi.YamlReader;
using Microsoft.OpenApi.Writers;

namespace Microsoft.OpenApi.Workbench
{
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi.Workbench/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Microsoft.OpenApi.Workbench"
xmlns:writers="clr-namespace:Microsoft.OpenApi.Writers;assembly=Microsoft.OpenApi"
xmlns:writers="clr-namespace:Microsoft.OpenApi;assembly=Microsoft.OpenApi"
mc:Ignorable="d"
Title="OpenAPI Workbench" Height="600" Width="800">
<Grid>
Expand Down
3 changes: 0 additions & 3 deletions src/Microsoft.OpenApi.Workbench/StatsVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

using System;
using System.Collections.Generic;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.Interfaces;
using Microsoft.OpenApi.Services;

namespace Microsoft.OpenApi.Workbench
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.YamlReader;
using Microsoft.OpenApi.YamlReader;

namespace Microsoft.OpenApi.Reader;

Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.OpenApi.YamlReader/OpenApiYamlReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Reader;
using SharpYaml.Serialization;
using Microsoft.OpenApi.Models;
using System;
using System.Linq;
using System.Text;
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Attributes/DisplayAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;

namespace Microsoft.OpenApi.Attributes
namespace Microsoft.OpenApi
{
/// <summary>
/// Represents the Open Api Data type metadata attribute.
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.OpenApi/Exceptions/OpenApiException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// Licensed under the MIT license.

using System;
using Microsoft.OpenApi.Properties;

namespace Microsoft.OpenApi.Exceptions
namespace Microsoft.OpenApi
{
/// <summary>
/// Exception type representing exceptions in the Open API library.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
// Licensed under the MIT license.

using System;
using System.Text.Json.Nodes;
using Microsoft.OpenApi.Reader;

namespace Microsoft.OpenApi.Exceptions
namespace Microsoft.OpenApi
{
/// <summary>
/// Defines an exception indicating OpenAPI Reader encountered an issue while reading.
/// </summary>
[Serializable]
public class OpenApiReaderException : OpenApiException

Check warning on line 13 in src/Microsoft.OpenApi/Exceptions/OpenApiReaderException.cs

View workflow job for this annotation

GitHub Actions / Build

Update this implementation of 'ISerializable' to conform to the recommended serialization pattern. Add a 'protected' constructor 'OpenApiReaderException(SerializationInfo, StreamingContext)'. (https://rules.sonarsource.com/csharp/RSPEC-3925)
{
/// <summary>
/// Initializes the <see cref="OpenApiReaderException"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
using System;
using System.Globalization;

namespace Microsoft.OpenApi.Exceptions
namespace Microsoft.OpenApi
{
/// <summary>
/// Defines an exception indicating OpenAPI Reader encountered an unsupported specification version while reading.
/// </summary>
[Serializable]
public class OpenApiUnsupportedSpecVersionException : Exception

Check warning on line 13 in src/Microsoft.OpenApi/Exceptions/OpenApiUnsupportedSpecVersionException.cs

View workflow job for this annotation

GitHub Actions / Build

Update this implementation of 'ISerializable' to conform to the recommended serialization pattern. Add a 'protected' constructor 'OpenApiUnsupportedSpecVersionException(SerializationInfo, StreamingContext)'. (https://rules.sonarsource.com/csharp/RSPEC-3925)
{
const string messagePattern = "OpenAPI specification version '{0}' is not supported.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// Licensed under the MIT license.

using System;
using Microsoft.OpenApi.Properties;

namespace Microsoft.OpenApi.Exceptions
namespace Microsoft.OpenApi
{
/// <summary>
/// Exception type representing exceptions in the OpenAPI writer.
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Expressions/BodyExpression.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.OpenApi.Expressions
namespace Microsoft.OpenApi
{
/// <summary>
/// Body expression.
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Expressions/CompositeExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Linq;
using System.Text.RegularExpressions;

namespace Microsoft.OpenApi.Expressions
namespace Microsoft.OpenApi
{
/// <summary>
/// String literal with embedded expressions
Expand All @@ -13,12 +13,12 @@
public class CompositeExpression : RuntimeExpression
{
private readonly string template;
private Regex expressionPattern = new(@"{(?<exp>\$[^}]*)");

Check warning on line 16 in src/Microsoft.OpenApi/Expressions/CompositeExpression.cs

View workflow job for this annotation

GitHub Actions / Build

Make 'expressionPattern' 'readonly'. (https://rules.sonarsource.com/csharp/RSPEC-2933)

Check warning on line 16 in src/Microsoft.OpenApi/Expressions/CompositeExpression.cs

View workflow job for this annotation

GitHub Actions / Build

Pass a timeout to limit the execution time. (https://rules.sonarsource.com/csharp/RSPEC-6444)

/// <summary>
/// Expressions embedded into string literal
/// </summary>
public List<RuntimeExpression> ContainedExpressions = new();

Check warning on line 21 in src/Microsoft.OpenApi/Expressions/CompositeExpression.cs

View workflow job for this annotation

GitHub Actions / Build

Make this field 'private' and encapsulate it in a 'public' property. (https://rules.sonarsource.com/csharp/RSPEC-1104)

/// <summary>
/// Create a composite expression from a string literal with an embedded expression
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Expressions/HeaderExpression.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.OpenApi.Expressions
namespace Microsoft.OpenApi
{
/// <summary>
/// Header expression, The token identifier in header is case-insensitive.
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Expressions/MethodExpression.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.OpenApi.Expressions
namespace Microsoft.OpenApi
{
/// <summary>
/// Method expression.
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Expressions/PathExpression.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.OpenApi.Expressions
namespace Microsoft.OpenApi
{
/// <summary>
/// Path expression, the name in path is case-sensitive.
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Expressions/QueryExpression.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.OpenApi.Expressions
namespace Microsoft.OpenApi
{
/// <summary>
/// Query expression, the name in query is case-sensitive.
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Expressions/RequestExpression.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.OpenApi.Expressions
namespace Microsoft.OpenApi
{
/// <summary>
/// $request. expression.
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Expressions/ResponseExpression.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.OpenApi.Expressions
namespace Microsoft.OpenApi
{
/// <summary>
/// $response. expression.
Expand Down
4 changes: 1 addition & 3 deletions src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
// Licensed under the MIT license.

using System;
using Microsoft.OpenApi.Exceptions;
using Microsoft.OpenApi.Properties;

namespace Microsoft.OpenApi.Expressions
namespace Microsoft.OpenApi
{
/// <summary>
/// Base class for the Open API runtime expression.
/// </summary>
public abstract class RuntimeExpression : IEquatable<RuntimeExpression>

Check warning on line 11 in src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs

View workflow job for this annotation

GitHub Actions / Build

Seal class 'RuntimeExpression' or implement 'IEqualityComparer<T>' instead. (https://rules.sonarsource.com/csharp/RSPEC-4035)
{
/// <summary>
/// The dollar sign prefix for a runtime expression.
Expand Down
4 changes: 1 addition & 3 deletions src/Microsoft.OpenApi/Expressions/SourceExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// Licensed under the MIT license.

using System;
using Microsoft.OpenApi.Exceptions;
using Microsoft.OpenApi.Properties;

namespace Microsoft.OpenApi.Expressions
namespace Microsoft.OpenApi
{
/// <summary>
/// Source expression.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.OpenApi.Expressions
namespace Microsoft.OpenApi
{
/// <summary>
/// StatusCode expression.
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Expressions/UrlExpression.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

namespace Microsoft.OpenApi.Expressions
namespace Microsoft.OpenApi
{
/// <summary>
/// Url expression.
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.OpenApi/Extensions/EnumExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using Microsoft.OpenApi.Attributes;

namespace Microsoft.OpenApi.Extensions
namespace Microsoft.OpenApi
{
/// <summary>
/// Enumeration type extension methods.
Expand Down
4 changes: 1 addition & 3 deletions src/Microsoft.OpenApi/Extensions/JsonNodeExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// Licensed under the MIT license.

using System.Text.Json.Nodes;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Writers;

namespace Microsoft.OpenApi.Extensions
namespace Microsoft.OpenApi
{
/// <summary>
/// A wrapper class for JsonNode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.OpenApi.Writers;

namespace Microsoft.OpenApi
namespace Microsoft.OpenApi
{
internal static class OpenAPIWriterExtensions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@

using System.Collections.Generic;
using System.Linq;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Services;
using Microsoft.OpenApi.Validations;

namespace Microsoft.OpenApi.Extensions
namespace Microsoft.OpenApi
{
/// <summary>
/// Extension methods that apply across all OpenAPIElements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
// Licensed under the MIT license.

using System;
using System.Collections.Generic;
using Microsoft.OpenApi.Exceptions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Properties;

namespace Microsoft.OpenApi.Extensions
namespace Microsoft.OpenApi
{
/// <summary>
/// Extension methods to verify validity and add an extension to Extensions property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.OpenApi.Exceptions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Properties;

namespace Microsoft.OpenApi.Extensions
namespace Microsoft.OpenApi
{
/// <summary>
/// Extension methods for resolving references on <see cref="IOpenApiReferenceable"/> elements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.OpenApi.Exceptions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Properties;
using Microsoft.OpenApi.Writers;

namespace Microsoft.OpenApi.Extensions
namespace Microsoft.OpenApi
{
/// <summary>
/// Extension methods for <see cref="IOpenApiSerializable"/> serialization.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Properties;

namespace Microsoft.OpenApi.Extensions;
namespace Microsoft.OpenApi;

/// <summary>
/// Extension methods for <see cref="OpenApiServer"/> serialization.
Expand Down
Loading
Loading