File tree Expand file tree Collapse file tree 3 files changed +57
-1
lines changed
Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiSchema
Microsoft.OpenApi.Tests/Models Expand file tree Collapse file tree 3 files changed +57
-1
lines changed Original file line number Diff line number Diff line change 1+ type : string
2+ examples :
3+ - fedora
4+ - ubuntu
Original file line number Diff line number Diff line change @@ -1614,7 +1614,33 @@ public void SerializeDocumentWithRootJsonSchemaDialectPropertyWorks()
16141614 var actual = doc . SerializeAsYaml ( OpenApiSpecVersion . OpenApi3_1 ) ;
16151615
16161616 // Assert
1617- Assert . Equal ( expected . MakeLineBreaksEnvironmentNeutral ( ) , actual . MakeLineBreaksEnvironmentNeutral ( ) ) ;
1617+ actual . MakeLineBreaksEnvironmentNeutral ( ) . Should ( ) . BeEquivalentTo ( expected . MakeLineBreaksEnvironmentNeutral ( ) ) ;
1618+ }
1619+
1620+ [ Fact ]
1621+ public void SerializeV31DocumentWithRefsInWebhooksWorks ( )
1622+ {
1623+ var expected = @"description: Returns all pets from the system that the user has access to
1624+ operationId: findPets
1625+ responses:
1626+ '200':
1627+ description: pet response
1628+ content:
1629+ application/json:
1630+ schema:
1631+ type: array
1632+ items:
1633+ type: object" ;
1634+
1635+ var doc = OpenApiDocument . Load ( "Models/Samples/docWithReusableWebhooks.yaml" ) . OpenApiDocument ;
1636+
1637+ var stringWriter = new StringWriter ( ) ;
1638+ var writer = new OpenApiYamlWriter ( stringWriter , new OpenApiWriterSettings { InlineLocalReferences = true } ) ;
1639+ var webhooks = doc . Webhooks [ "pets" ] . Operations ;
1640+
1641+ webhooks [ OperationType . Get ] . SerializeAsV31 ( writer ) ;
1642+ var actual = stringWriter . ToString ( ) ;
1643+ actual . MakeLineBreaksEnvironmentNeutral ( ) . Should ( ) . BeEquivalentTo ( expected . MakeLineBreaksEnvironmentNeutral ( ) ) ;
16181644 }
16191645 }
16201646}
Original file line number Diff line number Diff line change 1+ openapi : 3.1.0
2+ info :
3+ title : Webhook Example
4+ version : 1.0.0
5+ jsonSchemaDialect : " http://json-schema.org/draft-07/schema#"
6+ webhooks :
7+ pets :
8+ $ref : ' #/components/pathItems/pets'
9+ components :
10+ schemas :
11+ petSchema :
12+ type : object
13+ pathItems :
14+ pets :
15+ get :
16+ description : Returns all pets from the system that the user has access to
17+ operationId : findPets
18+ responses :
19+ ' 200 ' :
20+ description : pet response
21+ content :
22+ application/json :
23+ schema :
24+ type : array
25+ items :
26+ $ref : ' #/components/schemas/petSchema'
You can’t perform that action at this time.
0 commit comments