Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove generation of schemas in OpenAPI package #42169

Merged
merged 3 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swashbuckle will now read this information and populate the Schema, is that how it will work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

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