Skip to content

Commit c1a7106

Browse files
committed
Merge branch 'feat/oai-3-2-support' into copilot/fix-1e80ce48-c500-4024-9aa8-a50a721fd288
2 parents 41a231e + fb5c92f commit c1a7106

File tree

15 files changed

+293
-32
lines changed

15 files changed

+293
-32
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ trigger:
77
include:
88
- main
99
- support/v1
10+
- support/v2
1011
tags:
1112
include:
1213
- 'v*'
@@ -15,6 +16,7 @@ pr:
1516
include:
1617
- main
1718
- support/v1
19+
- support/v2
1820

1921
variables:
2022
buildPlatform: 'Any CPU'
@@ -307,6 +309,7 @@ extends:
307309
publishFeedCredentials: 'OpenAPI Nuget Connection'
308310

309311
- deployment: create_github_release
312+
condition: and(contains(variables['build.SourceBranch'], 'refs/tags/v'), succeeded())
310313
templateContext:
311314
type: releaseJob
312315
isProduction: true

.github/policies/OpenAPI.NET-branch-protection.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,39 @@ configuration:
8181
# Restrict who can dismiss pull request reviews. boolean
8282
restrictsReviewDismissals: false
8383

84+
- branchNamePattern: support/v2
85+
# This branch pattern applies to the following branches as of approximately 02/27/2025 15:28:20:
86+
# support/v1
87+
88+
# Specifies whether this branch can be deleted. boolean
89+
allowsDeletions: false
90+
# Specifies whether forced pushes are allowed on this branch. boolean
91+
allowsForcePushes: false
92+
# Specifies whether new commits pushed to the matching branches dismiss pull request review approvals. boolean
93+
dismissStaleReviews: true
94+
# Specifies whether admins can overwrite branch protection. boolean
95+
isAdminEnforced: true
96+
# Indicates whether "Require a pull request before merging" is enabled. boolean
97+
requiresPullRequestBeforeMerging: true
98+
# Specifies the number of pull request reviews before merging. int (0-6). Should be null/empty if PRs are not required
99+
requiredApprovingReviewsCount: 1
100+
# Require review from Code Owners. Requires requiredApprovingReviewsCount. boolean
101+
requireCodeOwnersReview: true
102+
# Are commits required to be signed. boolean. TODO: all contributors must have commit signing on local machines.
103+
requiresCommitSignatures: false
104+
# Are conversations required to be resolved before merging? boolean
105+
requiresConversationResolution: true
106+
# Are merge commits prohibited from being pushed to this branch. boolean
107+
requiresLinearHistory: false
108+
# Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status
109+
requiredStatusChecks:
110+
- license/cla
111+
- CodeQL
112+
- Continuous Integration
113+
# Require branches to be up to date before merging. boolean
114+
requiresStrictStatusChecks: false
115+
# Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush.
116+
restrictsPushes: false
117+
# Restrict who can dismiss pull request reviews. boolean
118+
restrictsReviewDismissals: false
119+

.github/release-please.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ primaryBranch: main
33
handleGHRelease: true
44
branches:
55
- branch: support/v1
6+
manifest: true
7+
handleGHRelease: true
8+
- branch: support/v2
69
manifest: true
710
handleGHRelease: true

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CodeQL Analysis
22

33
on:
44
push:
5-
branches: [ main, support/v1 ]
5+
branches: [ main, support/v1, support/v2 ]
66
pull_request:
77
schedule:
88
- cron: '0 8 * * *'

.github/workflows/release-please-gha.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ on:
1515
branches:
1616
- main
1717
- support/v1
18+
- support/v2
1819

1920
jobs:
2021
release:

src/Microsoft.OpenApi/Models/OpenApiConstants.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ public static class OpenApiConstants
245245
/// </summary>
246246
public const string Wrapped = "wrapped";
247247

248+
/// <summary>
249+
/// Field: NodeType
250+
/// </summary>
251+
public const string NodeType = "nodeType";
252+
248253
/// <summary>
249254
/// Field: In
250255
/// </summary>

src/Microsoft.OpenApi/Models/OpenApiXml.cs

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,40 @@ public class OpenApiXml : IOpenApiSerializable, IOpenApiExtensible
3030
/// Declares whether the property definition translates to an attribute instead of an element.
3131
/// Default value is false.
3232
/// </summary>
33-
public bool Attribute { get; set; }
33+
[Obsolete("Use NodeType property instead. This property will be removed in a future version.")]
34+
internal bool Attribute
35+
{
36+
get
37+
{
38+
return NodeType == OpenApiXmlNodeType.Attribute;
39+
}
40+
set
41+
{
42+
NodeType = value ? OpenApiXmlNodeType.Attribute : OpenApiXmlNodeType.None;
43+
}
44+
}
3445

3546
/// <summary>
3647
/// Signifies whether the array is wrapped.
3748
/// Default value is false.
3849
/// </summary>
39-
public bool Wrapped { get; set; }
50+
[Obsolete("Use NodeType property instead. This property will be removed in a future version.")]
51+
internal bool Wrapped
52+
{
53+
get
54+
{
55+
return NodeType == OpenApiXmlNodeType.Element;
56+
}
57+
set
58+
{
59+
NodeType = value ? OpenApiXmlNodeType.Element : OpenApiXmlNodeType.None;
60+
}
61+
}
62+
63+
/// <summary>
64+
/// The node type of the XML representation.
65+
/// </summary>
66+
public OpenApiXmlNodeType? NodeType { get; set; }
4067

4168
/// <summary>
4269
/// Specification Extensions.
@@ -56,8 +83,7 @@ public OpenApiXml(OpenApiXml xml)
5683
Name = xml?.Name ?? Name;
5784
Namespace = xml?.Namespace ?? Namespace;
5885
Prefix = xml?.Prefix ?? Prefix;
59-
Attribute = xml?.Attribute ?? Attribute;
60-
Wrapped = xml?.Wrapped ?? Wrapped;
86+
NodeType = xml?.NodeType ?? NodeType;
6187
Extensions = xml?.Extensions != null ? new Dictionary<string, IOpenApiExtension>(xml.Extensions) : null;
6288
}
6389

@@ -108,11 +134,25 @@ private void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
108134
// prefix
109135
writer.WriteProperty(OpenApiConstants.Prefix, Prefix);
110136

111-
// attribute
112-
writer.WriteProperty(OpenApiConstants.Attribute, Attribute, false);
113-
114-
// wrapped
115-
writer.WriteProperty(OpenApiConstants.Wrapped, Wrapped, false);
137+
// For OpenAPI 3.2.0 and above, serialize nodeType
138+
if (specVersion >= OpenApiSpecVersion.OpenApi3_2)
139+
{
140+
if (NodeType.HasValue)
141+
{
142+
writer.WriteProperty(OpenApiConstants.NodeType, NodeType.Value.GetDisplayName());
143+
}
144+
}
145+
else
146+
{
147+
// For OpenAPI 3.1.0 and below, serialize attribute and wrapped
148+
// Use backing fields if they were set via obsolete properties,
149+
// otherwise derive from NodeType if set
150+
var attribute = NodeType.HasValue && NodeType == OpenApiXmlNodeType.Attribute;
151+
var wrapped = NodeType.HasValue && NodeType == OpenApiXmlNodeType.Element;
152+
153+
writer.WriteProperty(OpenApiConstants.Attribute, attribute, false);
154+
writer.WriteProperty(OpenApiConstants.Wrapped, wrapped, false);
155+
}
116156

117157
// extensions
118158
writer.WriteExtensions(Extensions, specVersion);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
namespace Microsoft.OpenApi
5+
{
6+
/// <summary>
7+
/// The type of the XML node
8+
/// </summary>
9+
public enum OpenApiXmlNodeType
10+
{
11+
/// <summary>
12+
/// Element node type
13+
/// </summary>
14+
[Display("element")] Element,
15+
16+
/// <summary>
17+
/// Attribute node type
18+
/// </summary>
19+
[Display("attribute")] Attribute,
20+
21+
/// <summary>
22+
/// Text node type
23+
/// </summary>
24+
[Display("text")] Text,
25+
26+
/// <summary>
27+
/// CDATA node type
28+
/// </summary>
29+
[Display("cdata")] Cdata,
30+
31+
/// <summary>
32+
/// None node type
33+
/// </summary>
34+
[Display("none")] None
35+
}
36+
}

src/Microsoft.OpenApi/Reader/V2/OpenApiXmlDeserializer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ internal static partial class OpenApiV2Deserializer
4242
var attribute = n.GetScalarValue();
4343
if (attribute is not null)
4444
{
45+
#pragma warning disable CS0618 // Type or member is obsolete
4546
o.Attribute = bool.Parse(attribute);
47+
#pragma warning restore CS0618 // Type or member is obsolete
4648
}
4749
}
4850
},
@@ -53,7 +55,9 @@ internal static partial class OpenApiV2Deserializer
5355
var wrapped = n.GetScalarValue();
5456
if (wrapped is not null)
5557
{
58+
#pragma warning disable CS0618 // Type or member is obsolete
5659
o.Wrapped = bool.Parse(wrapped);
60+
#pragma warning restore CS0618 // Type or member is obsolete
5761
}
5862
}
5963
},

src/Microsoft.OpenApi/Reader/V3/OpenApiXmlDeserializer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ internal static partial class OpenApiV3Deserializer
3939
var attribute = n.GetScalarValue();
4040
if (attribute is not null)
4141
{
42+
#pragma warning disable CS0618 // Type or member is obsolete
4243
o.Attribute = bool.Parse(attribute);
44+
#pragma warning restore CS0618 // Type or member is obsolete
4345
}
4446
}
4547
},
@@ -50,7 +52,9 @@ internal static partial class OpenApiV3Deserializer
5052
var wrapped = n.GetScalarValue();
5153
if (wrapped is not null)
5254
{
55+
#pragma warning disable CS0618 // Type or member is obsolete
5356
o.Wrapped = bool.Parse(wrapped);
57+
#pragma warning restore CS0618 // Type or member is obsolete
5458
}
5559
}
5660
},

0 commit comments

Comments
 (0)