@@ -29,7 +29,6 @@ public List<OperationTemplate> CreateOperationTemplates(OpenApiDocument doc)
29
29
templateParameters = CreateTemplateParameters ( operation . Value . Parameters ) . ToArray ( ) ,
30
30
responses = CreateOperationResponses ( operation . Value . Responses ) . ToArray ( ) ,
31
31
request = CreateOperationRequest ( operation . Value ) ,
32
-
33
32
//unfinished
34
33
policies = null
35
34
}
@@ -46,7 +45,9 @@ public OperationTemplateRequest CreateOperationRequest(OpenApiOperation operatio
46
45
OperationTemplateRequest request = new OperationTemplateRequest ( )
47
46
{
48
47
description = operation . RequestBody != null ? operation . RequestBody . Description : null ,
48
+ // request parameters with parameter location query
49
49
queryParameters = CreateTemplateParameters ( operation . Parameters . Where ( p => p . In == ParameterLocation . Query ) . ToList ( ) ) . ToArray ( ) ,
50
+ // request parameters with parameter location header
50
51
headers = CreateTemplateParameters ( operation . Parameters . Where ( p => p . In == ParameterLocation . Header ) . ToList ( ) ) . ToArray ( ) ,
51
52
representations = operation . RequestBody != null ? CreateRepresentations ( operation . RequestBody . Content ) . ToArray ( ) : null
52
53
} ;
@@ -74,6 +75,7 @@ public List<OperationTemplateRepresentation> CreateRepresentations(IDictionary<s
74
75
List < OperationTemplateRepresentation > representations = new List < OperationTemplateRepresentation > ( ) ;
75
76
foreach ( KeyValuePair < string , OpenApiMediaType > pair in content )
76
77
{
78
+ // use representation examples to create values and default value
77
79
OpenApiParameterHeaderIntersection param = new OpenApiParameterHeaderIntersection ( )
78
80
{
79
81
Example = pair . Value . Example ,
@@ -123,6 +125,7 @@ public List<OperationTemplateParameter> CreateResponseHeaders(IDictionary<string
123
125
List < OperationTemplateParameter > headers = new List < OperationTemplateParameter > ( ) ;
124
126
foreach ( KeyValuePair < string , OpenApiHeader > pair in headerPairs )
125
127
{
128
+ // use header examples to create values and default value
126
129
OpenApiParameterHeaderIntersection param = new OpenApiParameterHeaderIntersection ( )
127
130
{
128
131
Example = pair . Value . Example ,
@@ -147,6 +150,7 @@ public List<OperationTemplateParameter> CreateTemplateParameters(IList<OpenApiPa
147
150
List < OperationTemplateParameter > templateParameters = new List < OperationTemplateParameter > ( ) ;
148
151
foreach ( OpenApiParameter parameter in parameters )
149
152
{
153
+ // use parameter examples to create values and default value
150
154
OpenApiParameterHeaderIntersection param = new OpenApiParameterHeaderIntersection ( )
151
155
{
152
156
Example = parameter . Example ,
@@ -171,11 +175,13 @@ public List<string> CreateParameterValues(OpenApiParameterHeaderIntersection par
171
175
List < string > values = new List < string > ( ) ;
172
176
if ( parameter . Example != null )
173
177
{
178
+ // add example property to values
174
179
values . Add ( JsonConvert . SerializeObject ( parameter . Example ) ) ;
175
180
176
181
}
177
182
foreach ( KeyValuePair < string , OpenApiExample > example in parameter . Examples )
178
183
{
184
+ // add each example in examples list property to values
179
185
values . Add ( JsonConvert . SerializeObject ( example . Value ) ) ;
180
186
}
181
187
return values ;
@@ -185,11 +191,13 @@ public string CreateParameterDefaultValue(OpenApiParameterHeaderIntersection par
185
191
{
186
192
if ( parameter . Example != null )
187
193
{
194
+ // use example property for default value if given
188
195
return JsonConvert . SerializeObject ( parameter . Example ) ;
189
196
190
197
}
191
198
else if ( parameter . Examples != null )
192
199
{
200
+ // use first example in examples list property for default value if example property is not given
193
201
return JsonConvert . SerializeObject ( parameter . Examples . SingleOrDefault ( ) . Value ) ;
194
202
}
195
203
else
@@ -199,11 +207,13 @@ public string CreateParameterDefaultValue(OpenApiParameterHeaderIntersection par
199
207
}
200
208
}
201
209
210
+ // used to create parameter values
202
211
public class OpenApiParameterHeaderIntersection {
203
212
public IOpenApiAny Example { get ; set ; }
204
213
public IDictionary < string , OpenApiExample > Examples { get ; set ; }
205
214
}
206
215
216
+ // used to give compiler known object structure in order to create form parameters
207
217
public class OperationSchemaExample
208
218
{
209
219
public object Value { get ; set ; }
0 commit comments