Skip to content

Commit

Permalink
Remove generation of schemas in OpenAPI package (#42169)
Browse files Browse the repository at this point in the history
* Remove generation of schemas in OpenAPI package

* Update src/OpenApi/test/OpenApiGeneratorTests.cs

Co-authored-by: Damian Edwards <damian@damianedwards.com>

* Update tests

Co-authored-by: Damian Edwards <damian@damianedwards.com>
  • Loading branch information
captainsafia and DamianEdwards committed Jun 17, 2022
1 parent 228ff77 commit 9304b39
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 272 deletions.
25 changes: 6 additions & 19 deletions src/OpenApi/src/OpenApiGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,12 @@ private static OpenApiResponses GetOpenApiResponses(MethodInfo method, EndpointM
foreach (var annotation in eligibileAnnotations)
{
var statusCode = annotation.Key.ToString(CultureInfo.InvariantCulture);
var (type, contentTypes) = annotation.Value;
var (_, contentTypes) = annotation.Value;
var responseContent = new Dictionary<string, OpenApiMediaType>();

foreach (var contentType in contentTypes)
{
responseContent[contentType] = new OpenApiMediaType
{
Schema = OpenApiSchemaGenerator.GetOpenApiSchema(type)
};
responseContent[contentType] = new OpenApiMediaType();
}

responses[statusCode] = new OpenApiResponse { Content = responseContent };
Expand Down Expand Up @@ -270,10 +267,7 @@ private static void GenerateDefaultResponses(Dictionary<int, (Type?, MediaTypeCo
{
foreach (var contentType in acceptsMetadata.ContentTypes)
{
requestBodyContent[contentType] = new OpenApiMediaType
{
Schema = OpenApiSchemaGenerator.GetOpenApiSchema(acceptsMetadata.RequestType ?? requestBodyParameter?.ParameterType)
};
requestBodyContent[contentType] = new OpenApiMediaType();
}
isRequired = !acceptsMetadata.IsOptional;
}
Expand All @@ -295,17 +289,11 @@ private static void GenerateDefaultResponses(Dictionary<int, (Type?, MediaTypeCo
var hasFormAttribute = requestBodyParameter.GetCustomAttributes().OfType<IFromFormMetadata>().FirstOrDefault() != null;
if (isFormType || hasFormAttribute)
{
requestBodyContent["multipart/form-data"] = new OpenApiMediaType
{
Schema = OpenApiSchemaGenerator.GetOpenApiSchema(requestBodyParameter.ParameterType)
};
requestBodyContent["multipart/form-data"] = new OpenApiMediaType();
}
else
{
requestBodyContent["application/json"] = new OpenApiMediaType
{
Schema = OpenApiSchemaGenerator.GetOpenApiSchema(requestBodyParameter.ParameterType)
};
requestBodyContent["application/json"] = new OpenApiMediaType();
}
}

Expand Down Expand Up @@ -389,10 +377,9 @@ private List<OpenApiParameter> GetOpenApiParameters(MethodInfo methodInfo, Endpo
var name = pattern.GetParameter(parameter.Name) is { } routeParameter ? routeParameter.Name : parameter.Name;
var openApiParameter = new OpenApiParameter()
{
Name = name,
Name = name,
In = parameterLocation,
Content = GetOpenApiParameterContent(metadata),
Schema = OpenApiSchemaGenerator.GetOpenApiSchema(parameter.ParameterType),
Required = !isOptional

};
Expand Down
77 changes: 0 additions & 77 deletions src/OpenApi/src/OpenApiSchemaGenerator.cs

This file was deleted.

Loading

0 comments on commit 9304b39

Please sign in to comment.