Skip to content

Commit e9ccd67

Browse files
committed
Adds a license SPDX identifier
1 parent 509d53c commit e9ccd67

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/Microsoft.OpenApi.Readers/V3/OpenApiLicenseDeserializer.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ internal static partial class OpenApiV3Deserializer
2222
o.Name = n.GetScalarValue();
2323
}
2424
},
25+
{
26+
"identifier", (o, n) =>
27+
{
28+
o.Identifier = n.GetScalarValue();
29+
}
30+
},
2531
{
2632
"url", (o, n) =>
2733
{

src/Microsoft.OpenApi/Models/OpenApiConstants.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ public static class OpenApiConstants
120120
/// </summary>
121121
public const string Name = "name";
122122

123+
/// <summary>
124+
/// Field: Identifier
125+
/// </summary>
126+
public const string Identifier = "identifier";
127+
123128
/// <summary>
124129
/// Field: Namespace
125130
/// </summary>

src/Microsoft.OpenApi/Models/OpenApiLicense.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public class OpenApiLicense : IOpenApiSerializable, IOpenApiExtensible
1919
/// </summary>
2020
public string Name { get; set; }
2121

22+
/// <summary>
23+
/// An SPDX license expression for the API. The identifier field is mutually exclusive of the url field.
24+
/// </summary>
25+
public string Identifier { get; set; }
26+
2227
/// <summary>
2328
/// The URL pointing to the contact information. MUST be in the format of a URL.
2429
/// </summary>
@@ -40,6 +45,7 @@ public OpenApiLicense() {}
4045
public OpenApiLicense(OpenApiLicense license)
4146
{
4247
Name = license?.Name ?? Name;
48+
Identifier = license?.Identifier ?? Identifier;
4349
Url = license?.Url != null ? new Uri(license.Url.OriginalString) : null;
4450
Extensions = license?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(license.Extensions) : null;
4551
}
@@ -72,6 +78,9 @@ private void WriteInternal(IOpenApiWriter writer, OpenApiSpecVersion specVersion
7278
// name
7379
writer.WriteProperty(OpenApiConstants.Name, Name);
7480

81+
// identifier
82+
writer.WriteProperty(OpenApiConstants.Identifier, Identifier);
83+
7584
// url
7685
writer.WriteProperty(OpenApiConstants.Url, Url?.OriginalString);
7786

0 commit comments

Comments
 (0)