Skip to content

Commit 6f335da

Browse files
committed
Address feedback
1 parent 5f9c92a commit 6f335da

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/OpenApi/src/Services/OpenApiDocumentService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private async Task<OpenApiResponse> GetResponseAsync(ApiDescription apiDescripti
228228
.Select(responseFormat => responseFormat.MediaType);
229229
foreach (var contentType in apiResponseFormatContentTypes)
230230
{
231-
var schema = apiResponseType.Type is { } type ? await _componentService.GetOrCreateSchemaAsync(type, null, cancellationToken, captureSchemaByRef: true) : new OpenApiSchema();
231+
var schema = apiResponseType.Type is { } type ? await _componentService.GetOrCreateSchemaAsync(type, null, captureSchemaByRef: true, cancellationToken) : new OpenApiSchema();
232232
response.Content[contentType] = new OpenApiMediaType { Schema = schema };
233233
}
234234

@@ -269,7 +269,7 @@ private async Task<OpenApiResponse> GetResponseAsync(ApiDescription apiDescripti
269269
_ => throw new InvalidOperationException($"Unsupported parameter source: {parameter.Source.Id}")
270270
},
271271
Required = IsRequired(parameter),
272-
Schema = await _componentService.GetOrCreateSchemaAsync(parameter.Type, parameter, cancellationToken),
272+
Schema = await _componentService.GetOrCreateSchemaAsync(parameter.Type, parameter, cancellationToken: cancellationToken),
273273
Description = GetParameterDescriptionFromAttribute(parameter)
274274
};
275275

@@ -347,7 +347,7 @@ private async Task<OpenApiRequestBody> GetFormRequestBody(IList<ApiRequestFormat
347347
if (parameter.All(parameter => parameter.ModelMetadata.ContainerType is null))
348348
{
349349
var description = parameter.Single();
350-
var parameterSchema = await _componentService.GetOrCreateSchemaAsync(description.Type, null, cancellationToken);
350+
var parameterSchema = await _componentService.GetOrCreateSchemaAsync(description.Type, null, cancellationToken: cancellationToken);
351351
// Form files are keyed by their parameter name so we must capture the parameter name
352352
// as a property in the schema.
353353
if (description.Type == typeof(IFormFile) || description.Type == typeof(IFormFileCollection))
@@ -410,15 +410,15 @@ private async Task<OpenApiRequestBody> GetFormRequestBody(IList<ApiRequestFormat
410410
var propertySchema = new OpenApiSchema { Type = "object", Properties = new Dictionary<string, OpenApiSchema>() };
411411
foreach (var description in parameter)
412412
{
413-
propertySchema.Properties[description.Name] = await _componentService.GetOrCreateSchemaAsync(description.Type, null, cancellationToken);
413+
propertySchema.Properties[description.Name] = await _componentService.GetOrCreateSchemaAsync(description.Type, null, cancellationToken: cancellationToken);
414414
}
415415
schema.AllOf.Add(propertySchema);
416416
}
417417
else
418418
{
419419
foreach (var description in parameter)
420420
{
421-
schema.Properties[description.Name] = await _componentService.GetOrCreateSchemaAsync(description.Type, null, cancellationToken);
421+
schema.Properties[description.Name] = await _componentService.GetOrCreateSchemaAsync(description.Type, null, cancellationToken: cancellationToken);
422422
}
423423
}
424424
}
@@ -465,7 +465,7 @@ private async Task<OpenApiRequestBody> GetJsonRequestBody(IList<ApiRequestFormat
465465
foreach (var requestForm in supportedRequestFormats)
466466
{
467467
var contentType = requestForm.MediaType;
468-
requestBody.Content[contentType] = new OpenApiMediaType { Schema = await _componentService.GetOrCreateSchemaAsync(bodyParameter.Type, bodyParameter, cancellationToken, captureSchemaByRef: true) };
468+
requestBody.Content[contentType] = new OpenApiMediaType { Schema = await _componentService.GetOrCreateSchemaAsync(bodyParameter.Type, bodyParameter, captureSchemaByRef: true, cancellationToken: cancellationToken) };
469469
}
470470

471471
return requestBody;

src/OpenApi/src/Services/Schemas/OpenApiSchemaService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ internal sealed class OpenApiSchemaService(
9696
// Short-circuit STJ's handling of nested properties, which uses a reference to the
9797
// properties type schema with a schema that uses a document level reference.
9898
// For example, if the property is a `public NestedTyped Nested { get; set; }` property,
99-
// "nested": "#/properties/nested" because "nested": "#/components/schemas/NestedType"
99+
// "nested": "#/properties/nested" becomes "nested": "#/components/schemas/NestedType"
100100
if (jsonPropertyInfo.PropertyType == jsonPropertyInfo.DeclaringType)
101101
{
102102
return new JsonObject { [OpenApiSchemaKeywords.RefKeyword] = context.TypeInfo.GetSchemaReferenceId() };
@@ -120,7 +120,7 @@ internal sealed class OpenApiSchemaService(
120120
}
121121
};
122122

123-
internal async Task<OpenApiSchema> GetOrCreateSchemaAsync(Type type, ApiParameterDescription? parameterDescription = null, CancellationToken cancellationToken = default, bool captureSchemaByRef = false)
123+
internal async Task<OpenApiSchema> GetOrCreateSchemaAsync(Type type, ApiParameterDescription? parameterDescription = null, bool captureSchemaByRef = false, CancellationToken cancellationToken = default)
124124
{
125125
var key = parameterDescription?.ParameterDescriptor is IParameterInfoParameterDescriptor parameterInfoDescription
126126
&& parameterDescription.ModelMetadata.PropertyName is null

0 commit comments

Comments
 (0)