Skip to content

Commit 49f3921

Browse files
committed
feat: implements inlining of referenced media types when serializing to 3 and 3.1
Signed-off-by: Vincent Biret <[email protected]>
1 parent 6c5f86f commit 49f3921

5 files changed

+60
-0
lines changed

src/Microsoft.OpenApi/Models/References/OpenApiMediaTypeReference.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,15 @@ protected override BaseOpenApiReference CopyReference(BaseOpenApiReference sourc
7474
{
7575
return new BaseOpenApiReference(sourceReference);
7676
}
77+
/// <inheritdoc/>
78+
public override void SerializeAsV31(IOpenApiWriter writer)
79+
{
80+
CopyReferenceAsTargetElementWithOverrides(new OpenApiMediaType()).SerializeAsV31(writer);
81+
}
82+
/// <inheritdoc/>
83+
public override void SerializeAsV3(IOpenApiWriter writer)
84+
{
85+
CopyReferenceAsTargetElementWithOverrides(new OpenApiMediaType()).SerializeAsV3(writer);
86+
}
7787
}
7888
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"openapi": "3.1.2",
3+
"info": {
4+
"title": "Test API",
5+
"version": "1.0.0"
6+
},
7+
"paths": {
8+
"/test": {
9+
"post": {
10+
"requestBody": {
11+
"content": {
12+
"application/json": {
13+
"schema": {
14+
"type": "object"
15+
}
16+
}
17+
}
18+
},
19+
"responses": { }
20+
}
21+
}
22+
},
23+
"components": { }
24+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"openapi":"3.1.2","info":{"title":"Test API","version":"1.0.0"},"paths":{"/test":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{}}}},"components":{}}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"openapi": "3.0.4",
3+
"info": {
4+
"title": "Test API",
5+
"version": "1.0.0"
6+
},
7+
"paths": {
8+
"/test": {
9+
"post": {
10+
"requestBody": {
11+
"content": {
12+
"application/json": {
13+
"schema": {
14+
"type": "object"
15+
}
16+
}
17+
}
18+
},
19+
"responses": { }
20+
}
21+
}
22+
},
23+
"components": { }
24+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"openapi":"3.0.4","info":{"title":"Test API","version":"1.0.0"},"paths":{"/test":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{}}}},"components":{}}

0 commit comments

Comments
 (0)