File tree Expand file tree Collapse file tree
test/Microsoft.OpenApi.Readers.Tests/V3Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Copyright (c) Microsoft Corporation. All rights reserved.
2+ // Licensed under the MIT license.
3+
4+ using Microsoft . OpenApi ;
5+ using Microsoft . OpenApi . Reader ;
6+ using Microsoft . OpenApi . Tests ;
7+ using Xunit ;
8+
9+ namespace Microsoft . OpenApi . Readers . Tests . V3Tests
10+ {
11+ [ Collection ( "DefaultSettings" ) ]
12+ public class OpenApiSubschemaReferenceTests
13+ {
14+ private const string Document = @"
15+ openapi: 3.0.3
16+ info:
17+ title: Subschema references
18+ version: 1.0.0
19+ paths: {}
20+ components:
21+ schemas:
22+ User:
23+ type: object
24+ properties:
25+ name:
26+ type: string
27+ address:
28+ type: object
29+ properties:
30+ city:
31+ type: string
32+ name:
33+ type: integer
34+ UserName:
35+ $ref: '#/components/schemas/User/properties/name'
36+ UserCity:
37+ $ref: '#/components/schemas/User/properties/address/properties/city'
38+ " ;
39+
40+ [ Fact ]
41+ public void ReferenceToComponentPropertyResolvesToThatProperty ( )
42+ {
43+ var document = OpenApiDocument . Parse ( Document , "yaml" , SettingsFixture . ReaderSettings ) . Document ;
44+
45+ var userName = Assert . IsType < OpenApiSchemaReference > ( document . Components . Schemas [ "UserName" ] ) ;
46+
47+ Assert . NotNull ( userName . Target ) ;
48+ Assert . Equal ( JsonSchemaType . String , userName . Target . Type ) ;
49+ Assert . Equal ( "#/components/schemas/User/properties/name" , userName . Reference . ReferenceV3 ) ;
50+ }
51+ }
52+ }
You can’t perform that action at this time.
0 commit comments