private void SetRequestExamples(OpenApiOperation operation, OperationFilterContext context) { var actionAttributes = context.GetControllerAndActionAttributes <SwaggerRequestExampleAttribute>(); foreach (var attr in actionAttributes) { var example = serviceProvider.GetExampleWithExamplesProviderType(attr.ExamplesProviderType); requestExample.SetRequestExampleForOperation( operation, context.SchemaRepository, attr.RequestType, example); } }
private void SetRequestModelExamples(OpenApiOperation operation, OperationFilterContext context) { var actionAttributes = context.MethodInfo.GetCustomAttributes <SwaggerRequestExampleAttribute>(); foreach (var attr in actionAttributes) { var example = serviceProvider.GetExampleWithExamplesProviderType(attr.ExamplesProviderType); requestExample.SetRequestExampleForOperation( operation, example, attr.ContractResolver, attr.JsonConverter); } }
private void SetRequestExamples(OpenApiOperation operation, OperationFilterContext context) { var actionAttributes = context.GetControllerAndActionAttributes <SwaggerRequestExampleAttribute>(); foreach (var parameterDescription in context.ApiDescription.ParameterDescriptions) { if (actionAttributes.Any(a => a.RequestType == parameterDescription.Type)) { continue; // if [SwaggerRequestExample] is defined, then let ExamplesOperationFilter define the example } var example = serviceProvider.GetExampleForType(parameterDescription.Type); requestExample.SetRequestExampleForOperation(operation, context.SchemaRepository, parameterDescription.Type, example); } }