|
1 | 1 | usingSystem; |
2 | 2 |
|
3 | | -namespaceMicrosoft.OpenApi.Reader.V31 |
| 3 | +namespaceMicrosoft.OpenApi.Reader.V31; |
| 4 | +/// <summary> |
| 5 | +/// Class containing logic to deserialize Open API V31 document into |
| 6 | +/// runtime Open API object model. |
| 7 | +/// </summary> |
| 8 | +internalstaticpartialclassOpenApiV31Deserializer |
4 | 9 | { |
5 | | -/// <summary> |
6 | | -/// Class containing logic to deserialize Open API V31 document into |
7 | | -/// runtime Open API object model. |
8 | | -/// </summary> |
9 | | -internalstaticpartialclassOpenApiV31Deserializer |
| 10 | +privatestaticreadonlyFixedFieldMap<OpenApiEncoding>_encodingFixedFields=new() |
10 | 11 | { |
11 | | -privatestaticreadonlyFixedFieldMap<OpenApiEncoding>_encodingFixedFields=new() |
12 | 12 | { |
| 13 | +"contentType",(o,n,_)=> |
13 | 14 | { |
14 | | -"contentType",(o,n,_)=> |
15 | | -{ |
16 | | -o.ContentType=n.GetScalarValue(); |
17 | | -} |
18 | | -}, |
| 15 | +o.ContentType=n.GetScalarValue(); |
| 16 | +} |
| 17 | +}, |
| 18 | +{ |
| 19 | +"headers",(o,n,t)=> |
19 | 20 | { |
20 | | -"headers",(o,n,t)=> |
21 | | -{ |
22 | | -o.Headers=n.CreateMap(LoadHeader,t); |
23 | | -} |
24 | | -}, |
| 21 | +o.Headers=n.CreateMap(LoadHeader,t); |
| 22 | +} |
| 23 | +}, |
| 24 | +{ |
| 25 | +"style",(o,n,_)=> |
25 | 26 | { |
26 | | -"style",(o,n,_)=> |
| 27 | +if(!n.GetScalarValue().TryGetEnumFromDisplayName<ParameterStyle>(n.Context,outvarstyle)) |
27 | 28 | { |
28 | | -if(!n.GetScalarValue().TryGetEnumFromDisplayName<ParameterStyle>(n.Context,outvarstyle)) |
29 | | -{ |
30 | | -return; |
31 | | -} |
32 | | -o.Style=style; |
| 29 | +return; |
33 | 30 | } |
34 | | -}, |
| 31 | +o.Style=style; |
| 32 | +} |
| 33 | +}, |
| 34 | +{ |
| 35 | +"explode",(o,n,_)=> |
35 | 36 | { |
36 | | -"explode",(o,n,_)=> |
| 37 | +varexplode=n.GetScalarValue(); |
| 38 | +if(explodeis notnull) |
37 | 39 | { |
38 | | -varexplode=n.GetScalarValue(); |
39 | | -if(explodeis notnull) |
40 | | -{ |
41 | | -o.Explode=bool.Parse(explode); |
42 | | -} |
43 | | -} |
44 | | -}, |
| 40 | +o.Explode=bool.Parse(explode); |
| 41 | +} |
| 42 | +} |
| 43 | +}, |
| 44 | +{ |
| 45 | +"allowReserved",(o,n,_)=> |
45 | 46 | { |
46 | | -"allowReserved",(o,n,_)=> |
| 47 | +varallowReserved=n.GetScalarValue(); |
| 48 | +if(allowReservedis notnull) |
47 | 49 | { |
48 | | -varallowReserved=n.GetScalarValue(); |
49 | | -if(allowReservedis notnull) |
50 | | -{ |
51 | | -o.AllowReserved=bool.Parse(allowReserved); |
52 | | -} |
| 50 | +o.AllowReserved=bool.Parse(allowReserved); |
53 | 51 | } |
54 | | -}, |
55 | | -}; |
56 | | - |
57 | | -privatestaticreadonlyPatternFieldMap<OpenApiEncoding>_encodingPatternFields= |
58 | | -new() |
59 | | -{ |
60 | | -{s=>s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix,StringComparison.OrdinalIgnoreCase),(o,p,n,_)=>o.AddExtension(p,LoadExtension(p,n))} |
61 | | -}; |
| 52 | +} |
| 53 | +}, |
| 54 | +}; |
62 | 55 |
|
63 | | -publicstaticOpenApiEncodingLoadEncoding(ParseNodenode,OpenApiDocumenthostDocument) |
| 56 | +privatestaticreadonlyPatternFieldMap<OpenApiEncoding>_encodingPatternFields= |
| 57 | +new() |
64 | 58 | { |
65 | | -varmapNode=node.CheckMapNode("encoding"); |
| 59 | +{s=>s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix,StringComparison.OrdinalIgnoreCase),(o,p,n,_)=>o.AddExtension(p,LoadExtension(p,n))} |
| 60 | +}; |
66 | 61 |
|
67 | | -varencoding=newOpenApiEncoding(); |
68 | | -foreach(varpropertyinmapNode) |
69 | | -{ |
70 | | -property.ParseField(encoding,_encodingFixedFields,_encodingPatternFields,hostDocument); |
71 | | -} |
| 62 | +publicstaticOpenApiEncodingLoadEncoding(ParseNodenode,OpenApiDocumenthostDocument) |
| 63 | +{ |
| 64 | +varmapNode=node.CheckMapNode("encoding"); |
72 | 65 |
|
73 | | -returnencoding; |
| 66 | +varencoding=newOpenApiEncoding(); |
| 67 | +foreach(varpropertyinmapNode) |
| 68 | +{ |
| 69 | +property.ParseField(encoding,_encodingFixedFields,_encodingPatternFields,hostDocument); |
74 | 70 | } |
| 71 | + |
| 72 | +returnencoding; |
75 | 73 | } |
76 | 74 | } |