Skip to content

Commit 1410672

Browse files
committed
Delete tests
1 parent bcb7fc7 commit 1410672

File tree

2 files changed

+1
-206
lines changed

2 files changed

+1
-206
lines changed

test/Microsoft.OpenApi.Readers.Tests/V3Tests/JsonSchemaTests.cs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -386,51 +386,5 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed()
386386
// Assert
387387
actual.Should().Be(expected);
388388
}
389-
390-
391-
[Fact]
392-
public void ParseSelfReferencingSchemaShouldNotStackOverflow()
393-
{
394-
using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "selfReferencingSchema.yaml"));
395-
// Act
396-
var openApiDoc = new OpenApiStreamReader().Read(stream, out var diagnostic);
397-
398-
// Assert
399-
var components = openApiDoc.Components;
400-
401-
diagnostic.Should().BeEquivalentTo(
402-
new OpenApiDiagnostic()
403-
{
404-
SpecificationVersion = OpenApiSpecVersion.OpenApi3_0,
405-
Errors = new List<OpenApiError>()
406-
{
407-
new OpenApiError("", "Paths is a REQUIRED field at #/")
408-
}
409-
});
410-
411-
var schemaExtension = new JsonSchemaBuilder()
412-
.AllOf(
413-
new JsonSchemaBuilder()
414-
.Title("schemaExtension")
415-
.Type(SchemaValueType.Object)
416-
.Properties(
417-
("description", new JsonSchemaBuilder().Type(SchemaValueType.String).Nullable(true)),
418-
("targetTypes", new JsonSchemaBuilder()
419-
.Type(SchemaValueType.Array)
420-
.Items(new JsonSchemaBuilder()
421-
.Type(SchemaValueType.String)
422-
)
423-
),
424-
("status", new JsonSchemaBuilder().Type(SchemaValueType.String)),
425-
("owner", new JsonSchemaBuilder().Type(SchemaValueType.String)),
426-
("child", null) // TODO (GSD): this isn't valid
427-
)
428-
);
429-
430-
//schemaExtension.AllOf[0].Properties["child"] = schemaExtension;
431-
432-
components.Schemas["microsoft.graph.schemaExtension"]
433-
.Should().BeEquivalentTo(components.Schemas["microsoft.graph.schemaExtension"].GetAllOf().ElementAt(0).GetProperties()["child"]);
434-
}
435389
}
436390
}

test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs

Lines changed: 1 addition & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System;
@@ -465,164 +465,5 @@ private static OpenApiDocument CreateDocWithSimpleSchemaToInline()
465465

466466
return doc;
467467
}
468-
469-
[Fact]
470-
471-
public void WriteInlineRecursiveSchema()
472-
{
473-
// Arrange
474-
var doc = CreateDocWithRecursiveSchemaReference();
475-
476-
var expected =
477-
@"openapi: 3.0.1
478-
info:
479-
title: Demo
480-
version: 1.0.0
481-
paths:
482-
/:
483-
get:
484-
responses:
485-
'200':
486-
description: OK
487-
content:
488-
application/json:
489-
schema:
490-
type: object
491-
properties:
492-
children:
493-
$ref: '#/components/schemas/thing'
494-
related:
495-
type: integer
496-
components:
497-
schemas:
498-
thing:
499-
type: object
500-
properties:
501-
children:
502-
type: object
503-
properties:
504-
children:
505-
$ref: '#/components/schemas/thing'
506-
related:
507-
type: integer
508-
related:
509-
type: integer";
510-
// Component schemas that are there due to cycles are still inlined because the items they reference may not exist in the components because they don't have cycles.
511-
512-
var outputString = new StringWriter(CultureInfo.InvariantCulture);
513-
var writer = new OpenApiYamlWriter(outputString, new OpenApiWriterSettings { InlineLocalReferences = true });
514-
515-
// Act
516-
doc.SerializeAsV3(writer);
517-
var actual = outputString.GetStringBuilder().ToString();
518-
519-
// Assert
520-
actual = actual.MakeLineBreaksEnvironmentNeutral();
521-
expected = expected.MakeLineBreaksEnvironmentNeutral();
522-
actual.Should().BeEquivalentTo(expected);
523-
Assert.Equal(expected, actual);
524-
}
525-
526-
private static OpenApiDocument CreateDocWithRecursiveSchemaReference()
527-
{
528-
var thingSchema = new JsonSchemaBuilder().Type(SchemaValueType.Object)
529-
.Ref("#/definitions/thing")
530-
.Properties(
531-
("children", new JsonSchemaBuilder().Ref("#/definitions/thing")),
532-
("related", new JsonSchemaBuilder().Type(SchemaValueType.Integer)))
533-
.Build();
534-
535-
var doc = new OpenApiDocument()
536-
{
537-
Info = new OpenApiInfo()
538-
{
539-
Title = "Demo",
540-
Version = "1.0.0"
541-
},
542-
Paths = new OpenApiPaths()
543-
{
544-
["/"] = new OpenApiPathItem
545-
{
546-
Operations = {
547-
[OperationType.Get] = new OpenApiOperation() {
548-
Responses = {
549-
["200"] = new OpenApiResponse {
550-
Description = "OK",
551-
Content = {
552-
["application/json"] = new OpenApiMediaType() {
553-
Schema = thingSchema
554-
}
555-
}
556-
}
557-
}
558-
}
559-
}
560-
}
561-
},
562-
Components = new OpenApiComponents
563-
{
564-
Schemas = {
565-
["thing"] = thingSchema}
566-
}
567-
};
568-
569-
return doc;
570-
}
571-
572-
[Fact]
573-
public void WriteInlineRecursiveSchemav2()
574-
{
575-
// Arrange
576-
var doc = CreateDocWithRecursiveSchemaReference();
577-
578-
var expected =
579-
@"swagger: '2.0'
580-
info:
581-
title: Demo
582-
version: 1.0.0
583-
paths:
584-
/:
585-
get:
586-
produces:
587-
- application/json
588-
responses:
589-
'200':
590-
description: OK
591-
schema:
592-
type: object
593-
properties:
594-
children:
595-
$ref: '#/definitions/thing'
596-
related:
597-
type: integer
598-
definitions:
599-
thing:
600-
type: object
601-
properties:
602-
children:
603-
type: object
604-
properties:
605-
children:
606-
$ref: '#/definitions/thing'
607-
related:
608-
type: integer
609-
related:
610-
type: integer";
611-
// Component schemas that are there due to cycles are still inlined because the items they reference may not exist in the components because they don't have cycles.
612-
613-
var outputString = new StringWriter(CultureInfo.InvariantCulture);
614-
var writer = new OpenApiYamlWriter(outputString, new OpenApiWriterSettings { InlineLocalReferences = true });
615-
616-
// Act
617-
doc.SerializeAsV2(writer);
618-
var actual = outputString.GetStringBuilder().ToString();
619-
620-
// Assert
621-
actual = actual.MakeLineBreaksEnvironmentNeutral();
622-
expected = expected.MakeLineBreaksEnvironmentNeutral();
623-
actual.Should().BeEquivalentTo(expected);
624-
Assert.Equal(expected, actual);
625-
}
626-
627468
}
628469
}

0 commit comments

Comments
 (0)