Skip to content

Commit 69307b3

Browse files
committed
Adjust
1 parent 167061f commit 69307b3

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

src/Microsoft.OpenApi/Models/OpenApiSchema.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,12 +1177,12 @@ private void SerializeNullable(IOpenApiWriter writer, OpenApiSpecVersion version
11771177
private (JsonSchemaType Type, string Format)? GetKnownTypeAndFormatPreOpenApi31()
11781178
{
11791179
// https://spec.openapis.org/oas/v3.2.0.html#migrating-binary-descriptions-from-oas-3-0
1180-
if (Type is not null && Type.Value.HasFlag(JsonSchemaType.String) && ContentEncoding == "base64")
1180+
if (Type == JsonSchemaType.String && ContentEncoding == "base64" && !string.IsNullOrEmpty(ContentMediaType))
11811181
{
1182-
return (Type.Value, "byte");
1182+
return (JsonSchemaType.String, "byte");
11831183
}
11841184

1185-
if (Type is null && !string.IsNullOrEmpty(ContentMediaType))
1185+
if (Type is null && ContentEncoding is null && !string.IsNullOrEmpty(ContentMediaType))
11861186
{
11871187
return (JsonSchemaType.String, "binary");
11881188
}

test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,8 +1554,6 @@ public async Task SerializeMissingPropertiesEmitsOaiExtensionsInV3()
15541554
{
15551555
var expected = JsonNode.Parse("""
15561556
{
1557-
"type": "string",
1558-
"format": "binary",
15591557
"x-jsonschema-$anchor": "root",
15601558
"x-jsonschema-contentEncoding": "base64",
15611559
"x-jsonschema-contentMediaType": "application/jwt",

0 commit comments

Comments
 (0)