Skip to content

Commit 7fcef5b

Browse files
authored
Merge branch 'vnext' into feature/add-path-signature-unique-validation
2 parents e6535f7 + 30d9969 commit 7fcef5b

File tree

12 files changed

+223
-28
lines changed

12 files changed

+223
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
The **OpenAPI.NET** SDK contains a useful object model for OpenAPI documents in .NET along with common serializers to extract raw OpenAPI JSON and YAML documents from the model.
1212

13-
**See more information on the OpenAPI specification and its history here: <a href="https://www.openapis.org">Open API Initiative</a>**
13+
**See more information on the OpenAPI specification and its history here: <a href="https://www.openapis.org">OpenAPI Initiative</a>**
1414

1515
Project Objectives
1616

build.cmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
Echo Building Microsoft.OpenApi
33

44
SET PROJ=%~dp0src\Microsoft.OpenApi\Microsoft.OpenApi.csproj
5-
dotnet build %PROJ% /t:restore /p:Configuration=Release
6-
dotnet build %PROJ% /t:build /p:Configuration=Release
7-
dotnet build %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts
5+
dotnet msbuild %PROJ% /t:restore /p:Configuration=Release
6+
dotnet msbuild %PROJ% /t:build /p:Configuration=Release
7+
dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts
88

99
Echo Building Microsoft.OpenApi.Readers
1010

1111
SET PROJ=%~dp0src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj
12-
dotnet build %PROJ% /t:restore /p:Configuration=Release
13-
dotnet build %PROJ% /t:build /p:Configuration=Release
14-
dotnet build %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts
12+
dotnet msbuild %PROJ% /t:restore /p:Configuration=Release
13+
dotnet msbuild %PROJ% /t:build /p:Configuration=Release
14+
dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts
1515

1616
goto :end
1717
:error

src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Company>Microsoft</Company>
1111
<Title>Microsoft.OpenApi.Readers</Title>
1212
<PackageId>Microsoft.OpenApi.Readers</PackageId>
13-
<Version>1.2.0-preview.3</Version>
13+
<Version>1.2.1</Version>
1414
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
1515
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1616
<PackageTags>OpenAPI .NET</PackageTags>

src/Microsoft.OpenApi.Readers/OpenApiTextReaderReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public OpenApiDocument Read(TextReader input, out OpenApiDiagnostic diagnostic)
3737
{
3838
YamlDocument yamlDocument;
3939

40-
// Parse the YAML/JSON
40+
// Parse the YAML/JSON text in the TextReader into the YamlDocument
4141
try
4242
{
4343
yamlDocument = LoadYamlDocument(input);

src/Microsoft.OpenApi/Any/OpenApiString.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@ public class OpenApiString : OpenApiPrimitive<string>
1010
{
1111
private bool isExplicit;
1212

13+
/// <summary>
14+
/// Initializes the <see cref="OpenApiString"/> class.
15+
/// </summary>
16+
/// <param name="value"></param>
17+
public OpenApiString(string value)
18+
: this(value, false)
19+
{
20+
}
21+
1322
/// <summary>
1423
/// Initializes the <see cref="OpenApiString"/> class.
1524
/// </summary>
1625
/// <param name="value"></param>
1726
/// <param name="isExplicit">Used to indicate if a string is quoted.</param>
18-
public OpenApiString(string value, bool isExplicit = false)
27+
public OpenApiString(string value, bool isExplicit)
1928
: base(value)
2029
{
2130
this.isExplicit = isExplicit;

src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs

100644100755
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@ public static void SerializeAsYaml<T>(this T element, Stream stream, OpenApiSpec
4141
element.Serialize(stream, specVersion, OpenApiFormat.Yaml);
4242
}
4343

44+
/// <summary>
45+
/// Serializes the <see cref="IOpenApiSerializable"/> to the Open API document using
46+
/// the given stream, specification version and the format.
47+
/// </summary>
48+
/// <typeparam name="T">the <see cref="IOpenApiSerializable"/></typeparam>
49+
/// <param name="element">The Open API element.</param>
50+
/// <param name="stream">The given stream.</param>
51+
/// <param name="specVersion">The Open API specification version.</param>
52+
/// <param name="format">The output format (JSON or YAML).</param>
53+
public static void Serialize<T>(
54+
this T element,
55+
Stream stream,
56+
OpenApiSpecVersion specVersion,
57+
OpenApiFormat format)
58+
where T : IOpenApiSerializable
59+
{
60+
element.Serialize(stream, specVersion, format, null);
61+
}
62+
4463
/// <summary>
4564
/// Serializes the <see cref="IOpenApiSerializable"/> to the Open API document using
4665
/// the given stream, specification version and the format.
@@ -56,7 +75,7 @@ public static void Serialize<T>(
5675
Stream stream,
5776
OpenApiSpecVersion specVersion,
5877
OpenApiFormat format,
59-
OpenApiWriterSettings settings = null)
78+
OpenApiWriterSettings settings)
6079
where T : IOpenApiSerializable
6180
{
6281
if (stream == null)

src/Microsoft.OpenApi/Microsoft.OpenApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Company>Microsoft</Company>
1111
<Title>Microsoft.OpenApi</Title>
1212
<PackageId>Microsoft.OpenApi</PackageId>
13-
<Version>1.2.0-preview.3</Version>
13+
<Version>1.2.1</Version>
1414
<Description>.NET models with JSON and YAML writers for OpenAPI specification</Description>
1515
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1616
<PackageTags>OpenAPI .NET</PackageTags>

src/Microsoft.OpenApi/Models/OpenApiOperation.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ public void SerializeAsV2(IOpenApiWriter writer)
248248
// Our library does not support this at the moment.
249249
Name = "body",
250250
Schema = content?.Schema ?? new OpenApiSchema(),
251-
Required = RequestBody.Required
251+
Required = RequestBody.Required,
252+
Extensions = RequestBody.Extensions
252253
};
253254

254255
parameters.Add(bodyParameter);

src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs

100644100755
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@ namespace Microsoft.OpenApi.Writers
1010
/// </summary>
1111
public class OpenApiJsonWriter : OpenApiWriterBase
1212
{
13+
/// <summary>
14+
/// Initializes a new instance of the <see cref="OpenApiJsonWriter"/> class.
15+
/// </summary>
16+
/// <param name="textWriter">The text writer.</param>
17+
public OpenApiJsonWriter(TextWriter textWriter) : base(textWriter, null)
18+
{
19+
}
20+
1321
/// <summary>
1422
/// Initializes a new instance of the <see cref="OpenApiJsonWriter"/> class.
1523
/// </summary>
1624
/// <param name="textWriter">The text writer.</param>
1725
/// <param name="settings">Settings for controlling how the OpenAPI document will be written out.</param>
18-
public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings settings = null) : base(textWriter, settings)
26+
public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings settings) : base(textWriter, settings)
1927
{
2028
}
2129

src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs

100644100755
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Collections.Generic;
66
using System.IO;
77
using Microsoft.OpenApi.Exceptions;
8-
using Microsoft.OpenApi.Models;
98
using Microsoft.OpenApi.Properties;
109

1110
namespace Microsoft.OpenApi.Writers
@@ -24,7 +23,7 @@ public abstract class OpenApiWriterBase : IOpenApiWriter
2423
/// <summary>
2524
/// The indentation string to prepand to each line for each indentation level.
2625
/// </summary>
27-
private const string IndentationString = " ";
26+
protected const string IndentationString = " ";
2827

2928
/// <summary>
3029
/// Scope of the Open API element - object, array, property.
@@ -40,25 +39,27 @@ public abstract class OpenApiWriterBase : IOpenApiWriter
4039
/// Initializes a new instance of the <see cref="OpenApiWriterBase"/> class.
4140
/// </summary>
4241
/// <param name="textWriter">The text writer.</param>
43-
public OpenApiWriterBase(TextWriter textWriter)
42+
public OpenApiWriterBase(TextWriter textWriter) : this(textWriter, null)
4443
{
45-
Writer = textWriter;
46-
Writer.NewLine = "\n";
47-
48-
Scopes = new Stack<Scope>();
4944
}
5045

5146
/// <summary>
52-
///
47+
/// Initializes a new instance of the <see cref="OpenApiWriterBase"/> class.
5348
/// </summary>
5449
/// <param name="textWriter"></param>
5550
/// <param name="settings"></param>
56-
public OpenApiWriterBase(TextWriter textWriter, OpenApiWriterSettings settings = null) : this(textWriter)
51+
public OpenApiWriterBase(TextWriter textWriter, OpenApiWriterSettings settings)
5752
{
53+
Writer = textWriter;
54+
Writer.NewLine = "\n";
55+
56+
Scopes = new Stack<Scope>();
57+
5858
if (settings == null)
5959
{
6060
settings = new OpenApiWriterSettings();
6161
}
62+
6263
Settings = settings;
6364
}
6465

0 commit comments

Comments
 (0)