|
9 | 9 | using System.Threading.Tasks;
|
10 | 10 | using Microsoft.OpenApi.Any;
|
11 | 11 | using Microsoft.OpenApi.Extensions;
|
12 |
| -using Microsoft.OpenApi.Interfaces; |
13 | 12 | using Microsoft.OpenApi.Models;
|
14 | 13 | using Microsoft.OpenApi.Models.Interfaces;
|
15 | 14 | using Microsoft.OpenApi.Models.References;
|
16 | 15 | using Microsoft.OpenApi.Writers;
|
17 |
| -using Microsoft.VisualBasic; |
18 | 16 | using VerifyXunit;
|
19 | 17 | using Xunit;
|
20 | 18 |
|
@@ -2179,7 +2177,7 @@ public void SerializeAsThrowsIfVersionIsNotSupported()
|
2179 | 2177 | }
|
2180 | 2178 |
|
2181 | 2179 | [Fact]
|
2182 |
| - public async Task SerializeDocWithSecuritySchemeWithInlineRefererencesWorks() |
| 2180 | + public async Task SerializeDocWithSecuritySchemeWithInlineReferencesWorks() |
2183 | 2181 | {
|
2184 | 2182 | var expected = @"openapi: 3.0.4
|
2185 | 2183 | info:
|
@@ -2220,5 +2218,70 @@ public async Task SerializeDocWithSecuritySchemeWithInlineRefererencesWorks()
|
2220 | 2218 | var actual = stringWriter.ToString();
|
2221 | 2219 | Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), actual.MakeLineBreaksEnvironmentNeutral());
|
2222 | 2220 | }
|
| 2221 | + |
| 2222 | + [Fact] |
| 2223 | + public async Task SerializeDocWithoutOperationSecurityWorks() |
| 2224 | + { |
| 2225 | + var expected = """ |
| 2226 | + openapi: 3.0.4 |
| 2227 | + info: |
| 2228 | + title: Repair Service |
| 2229 | + version: 1.0.0 |
| 2230 | + servers: |
| 2231 | + - url: https://pluginrentu.azurewebsites.net/api |
| 2232 | + paths: |
| 2233 | + /repairs: |
| 2234 | + get: |
| 2235 | + summary: List all repairs |
| 2236 | + description: Returns a list of repairs with their details and images |
| 2237 | + operationId: listRepairs |
| 2238 | + responses: |
| 2239 | + '200': |
| 2240 | + description: A list of repairs |
| 2241 | + content: |
| 2242 | + application/json: |
| 2243 | + schema: |
| 2244 | + type: object |
| 2245 | + """; |
| 2246 | + |
| 2247 | + var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithoutOperationSecurity.yaml", SettingsFixture.ReaderSettings)).Document; |
| 2248 | + var stringWriter = new StringWriter(); |
| 2249 | + doc!.SerializeAsV3(new OpenApiYamlWriter(stringWriter, new OpenApiWriterSettings { InlineLocalReferences = true })); |
| 2250 | + var actual = stringWriter.ToString(); |
| 2251 | + Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), actual.MakeLineBreaksEnvironmentNeutral()); |
| 2252 | + } |
| 2253 | + |
| 2254 | + [Fact] |
| 2255 | + public async Task SerializeDocWithEmptyOperationSecurityWorks() |
| 2256 | + { |
| 2257 | + var expected = """ |
| 2258 | + openapi: 3.0.4 |
| 2259 | + info: |
| 2260 | + title: Repair Service |
| 2261 | + version: 1.0.0 |
| 2262 | + servers: |
| 2263 | + - url: https://pluginrentu.azurewebsites.net/api |
| 2264 | + paths: |
| 2265 | + /repairs: |
| 2266 | + get: |
| 2267 | + summary: List all repairs |
| 2268 | + description: Returns a list of repairs with their details and images |
| 2269 | + operationId: listRepairs |
| 2270 | + responses: |
| 2271 | + '200': |
| 2272 | + description: A list of repairs |
| 2273 | + content: |
| 2274 | + application/json: |
| 2275 | + schema: |
| 2276 | + type: object |
| 2277 | + security: [ ] |
| 2278 | + """; |
| 2279 | + |
| 2280 | + var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithEmptyOperationSecurity.yaml", SettingsFixture.ReaderSettings)).Document; |
| 2281 | + var stringWriter = new StringWriter(); |
| 2282 | + doc!.SerializeAsV3(new OpenApiYamlWriter(stringWriter, new OpenApiWriterSettings { InlineLocalReferences = true })); |
| 2283 | + var actual = stringWriter.ToString(); |
| 2284 | + Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), actual.MakeLineBreaksEnvironmentNeutral()); |
| 2285 | + } |
2223 | 2286 | }
|
2224 | 2287 | }
|
0 commit comments