File tree Expand file tree Collapse file tree 2 files changed +75
-0
lines changed
test/Microsoft.OpenApi.Tests/Models Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change @@ -2179,5 +2179,48 @@ public void SerializeAsThrowsIfVersionIsNotSupported()
21792179 Assert . Equal ( "version" , actual . ParamName ) ;
21802180 Assert . Equal ( version , actual . ActualValue ) ;
21812181 }
2182+
2183+ [ Fact ]
2184+ public async Task SerializeDocWithSecuritySchemeWithInlineRefererencesWorks ( )
2185+ {
2186+ var expected = @"openapi: 3.0.4
2187+ info:
2188+ title: Repair Service
2189+ version: 1.0.0
2190+ servers:
2191+ - url: https://pluginrentu.azurewebsites.net/api
2192+ paths:
2193+ /repairs:
2194+ get:
2195+ summary: List all repairs with oauth
2196+ description: Returns a list of repairs with their details and images
2197+ operationId: listRepairs
2198+ responses:
2199+ '200':
2200+ description: A list of repairs
2201+ content:
2202+ application/json:
2203+ schema:
2204+ type: object
2205+ security:
2206+ - oAuth2AuthCode: [ ]
2207+ components:
2208+ securitySchemes:
2209+ oAuth2AuthCode:
2210+ type: oauth2
2211+ description: OAuth configuration for the repair service
2212+ flows:
2213+ authorizationCode:
2214+ authorizationUrl: https://login.microsoftonline.com/2f13b28c-bd4d-43e2-8ae6-48594aaba125/oauth2/v2.0/authorize
2215+ tokenUrl: https://login.microsoftonline.com/2f13b28c-bd4d-43e2-8ae6-48594aaba125/oauth2/v2.0/token
2216+ scopes:
2217+ api://a2a7226d-e8d1-4ded-8c53-dd4c136ff456/repairs_read: Read repair records" ;
2218+
2219+ var doc = ( await OpenApiDocument . LoadAsync ( "Models/Samples/docWithSecurityScheme.yaml" , SettingsFixture . ReaderSettings ) ) . Document ;
2220+ var stringWriter = new StringWriter ( ) ;
2221+ doc . SerializeAsV3 ( new OpenApiYamlWriter ( stringWriter , new OpenApiWriterSettings { InlineLocalReferences = true } ) ) ;
2222+ var actual = stringWriter . ToString ( ) ;
2223+ Assert . Equal ( expected . MakeLineBreaksEnvironmentNeutral ( ) , actual . MakeLineBreaksEnvironmentNeutral ( ) ) ;
2224+ }
21822225 }
21832226}
Original file line number Diff line number Diff line change 1+ openapi : 3.0.0
2+ info :
3+ title : Repair Service
4+ version : 1.0.0
5+ servers :
6+ - url : https://pluginrentu.azurewebsites.net/api
7+ components :
8+ securitySchemes :
9+ oAuth2AuthCode :
10+ type : oauth2
11+ description : OAuth configuration for the repair service
12+ flows :
13+ authorizationCode :
14+ authorizationUrl : https://login.microsoftonline.com/2f13b28c-bd4d-43e2-8ae6-48594aaba125/oauth2/v2.0/authorize
15+ tokenUrl : https://login.microsoftonline.com/2f13b28c-bd4d-43e2-8ae6-48594aaba125/oauth2/v2.0/token
16+ scopes :
17+ api://a2a7226d-e8d1-4ded-8c53-dd4c136ff456/repairs_read : Read repair records
18+ paths :
19+ /repairs :
20+ get :
21+ operationId : listRepairs
22+ summary : List all repairs with oauth
23+ description : Returns a list of repairs with their details and images
24+ security :
25+ - oAuth2AuthCode : []
26+ responses :
27+ ' 200 ' :
28+ description : A list of repairs
29+ content :
30+ application/json :
31+ schema :
32+ type : object
You can’t perform that action at this time.
0 commit comments