Skip to content

Commit 4f50202

Browse files
committed
Update OAuthServerMetadata.cs
1 parent cb8b7df commit 4f50202

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

tests/ModelContextProtocol.TestOAuthServer/OAuthServerMetadata.cs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,24 @@ internal sealed class OAuthServerMetadata
3333
/// OPTIONAL. URL of the authorization server's JWK Set document.
3434
/// </summary>
3535
[JsonPropertyName("jwks_uri")]
36-
public required string JwksUri { get; init; }
36+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
37+
public string? JwksUri { get; init; }
3738

3839
/// <summary>
3940
/// Gets or sets the registration endpoint URL for dynamic client registration.
4041
/// OPTIONAL. URL of the authorization server's OAuth 2.0 Dynamic Client Registration endpoint.
4142
/// </summary>
4243
[JsonPropertyName("registration_endpoint")]
44+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
4345
public string? RegistrationEndpoint { get; init; }
4446

4547
/// <summary>
4648
/// Gets or sets the scopes supported by this server.
4749
/// RECOMMENDED. JSON array containing a list of the OAuth 2.0 scope values that this server supports.
4850
/// </summary>
4951
[JsonPropertyName("scopes_supported")]
50-
public required List<string> ScopesSupported { get; init; }
52+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
53+
public List<string>? ScopesSupported { get; init; }
5154

5255
/// <summary>
5356
/// Gets or sets the response types supported by this server.
@@ -61,97 +64,111 @@ internal sealed class OAuthServerMetadata
6164
/// OPTIONAL. JSON array containing a list of the OAuth 2.0 "response_mode" values that this server supports.
6265
/// </summary>
6366
[JsonPropertyName("response_modes_supported")]
67+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
6468
public List<string>? ResponseModesSupported { get; init; }
6569

6670
/// <summary>
6771
/// Gets or sets the grant types supported by this server.
6872
/// OPTIONAL. JSON array containing a list of the OAuth 2.0 grant type values that this server supports.
6973
/// </summary>
7074
[JsonPropertyName("grant_types_supported")]
71-
public required List<string> GrantTypesSupported { get; init; }
75+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
76+
public List<string>? GrantTypesSupported { get; init; }
7277

7378
/// <summary>
7479
/// Gets or sets the token endpoint authentication methods supported by this server.
7580
/// OPTIONAL. JSON array containing a list of client authentication methods supported by this token endpoint.
7681
/// </summary>
7782
[JsonPropertyName("token_endpoint_auth_methods_supported")]
78-
public required List<string> TokenEndpointAuthMethodsSupported { get; init; }
83+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
84+
public List<string>? TokenEndpointAuthMethodsSupported { get; init; }
7985

8086
/// <summary>
8187
/// Gets or sets the token endpoint authentication signing algorithms supported by this server.
8288
/// OPTIONAL. JSON array containing a list of the JWS signing algorithms supported by the token endpoint.
8389
/// </summary>
8490
[JsonPropertyName("token_endpoint_auth_signing_alg_values_supported")]
91+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
8592
public List<string>? TokenEndpointAuthSigningAlgValuesSupported { get; init; }
8693

8794
/// <summary>
8895
/// Gets or sets the introspection endpoint URL.
8996
/// OPTIONAL. URL of the authorization server's OAuth 2.0 introspection endpoint.
9097
/// </summary>
9198
[JsonPropertyName("introspection_endpoint")]
92-
public required string IntrospectionEndpoint { get; init; }
99+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
100+
public string? IntrospectionEndpoint { get; init; }
93101

94102
/// <summary>
95103
/// Gets or sets the introspection endpoint authentication methods supported by this server.
96104
/// OPTIONAL. JSON array containing a list of client authentication methods supported by this introspection endpoint.
97105
/// </summary>
98106
[JsonPropertyName("introspection_endpoint_auth_methods_supported")]
107+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
99108
public List<string>? IntrospectionEndpointAuthMethodsSupported { get; init; }
100109

101110
/// <summary>
102111
/// Gets or sets the introspection endpoint authentication signing algorithms supported by this server.
103112
/// OPTIONAL. JSON array containing a list of the JWS signing algorithms supported by the introspection endpoint.
104113
/// </summary>
105114
[JsonPropertyName("introspection_endpoint_auth_signing_alg_values_supported")]
115+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
106116
public List<string>? IntrospectionEndpointAuthSigningAlgValuesSupported { get; init; }
107117

108118
/// <summary>
109119
/// Gets or sets the revocation endpoint URL.
110120
/// OPTIONAL. URL of the authorization server's OAuth 2.0 revocation endpoint.
111121
/// </summary>
112122
[JsonPropertyName("revocation_endpoint")]
123+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
113124
public string? RevocationEndpoint { get; init; }
114125

115126
/// <summary>
116127
/// Gets or sets the revocation endpoint authentication methods supported by this server.
117128
/// OPTIONAL. JSON array containing a list of client authentication methods supported by this revocation endpoint.
118129
/// </summary>
119130
[JsonPropertyName("revocation_endpoint_auth_methods_supported")]
131+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
120132
public List<string>? RevocationEndpointAuthMethodsSupported { get; init; }
121133

122134
/// <summary>
123135
/// Gets or sets the revocation endpoint authentication signing algorithms supported by this server.
124136
/// OPTIONAL. JSON array containing a list of the JWS signing algorithms supported by the revocation endpoint.
125137
/// </summary>
126138
[JsonPropertyName("revocation_endpoint_auth_signing_alg_values_supported")]
139+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
127140
public List<string>? RevocationEndpointAuthSigningAlgValuesSupported { get; init; }
128141

129142
/// <summary>
130143
/// Gets or sets the code challenge methods supported by this server.
131144
/// OPTIONAL. JSON array containing a list of Proof Key for Code Exchange (PKCE) code challenge methods supported by this server.
132145
/// </summary>
133146
[JsonPropertyName("code_challenge_methods_supported")]
134-
public required List<string> CodeChallengeMethodsSupported { get; init; }
147+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
148+
public List<string>? CodeChallengeMethodsSupported { get; init; }
135149

136150
// OpenID Connect specific fields that are commonly included in OAuth metadata
137151
/// <summary>
138152
/// Gets or sets the subject types supported by this server.
139153
/// REQUIRED for OpenID Connect. JSON array containing a list of the Subject Identifier types that this OP supports.
140154
/// </summary>
141155
[JsonPropertyName("subject_types_supported")]
142-
public required List<string> SubjectTypesSupported { get; init; }
156+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
157+
public List<string>? SubjectTypesSupported { get; init; }
143158

144159
/// <summary>
145160
/// Gets or sets the ID token signing algorithms supported by this server.
146161
/// REQUIRED for OpenID Connect. JSON array containing a list of the JWS signing algorithms (alg values) supported by the OP for the ID Token.
147162
/// </summary>
148163
[JsonPropertyName("id_token_signing_alg_values_supported")]
149-
public required List<string> IdTokenSigningAlgValuesSupported { get; init; }
164+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
165+
public List<string>? IdTokenSigningAlgValuesSupported { get; init; }
150166

151167
/// <summary>
152168
/// Gets or sets the claims supported by this server.
153169
/// RECOMMENDED for OpenID Connect. JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for.
154170
/// </summary>
155171
[JsonPropertyName("claims_supported")]
156-
public required List<string> ClaimsSupported { get; init; }
172+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
173+
public List<string>? ClaimsSupported { get; init; }
157174
}

0 commit comments

Comments
 (0)