Beispiel #1
0
        private Func <IErrorWrapper> CreateWrapperFunction()
        {
            var wrapperType = _errorResultTypeCreator.GenerateErrorType();

            var newExpression = Expression.New(wrapperType);

            var lambda = Expression.Lambda <Func <IErrorWrapper> >(newExpression);

            return(lambda.Compile());
        }
Beispiel #2
0
        private void GenerateErrorResponse(IEndPointMethodHandler endPointMethodHandler, OpenApiResponses responses)
        {
            if (!responses.ContainsKey("500"))
            {
                var response = new OpenApiResponse {
                    Description = "Internal Server Error"
                };

                var contentDictionary = response.Content = new Dictionary <string, OpenApiMediaType>();
                var responseSchema    = _apiSchemaGenerator.GetSchemaType(_errorResultTypeCreator.GenerateErrorType());

                foreach (var supportedContentType in _contentSerializationService.SupportedContentTypes)
                {
                    contentDictionary[supportedContentType] = new OpenApiMediaType
                    {
                        Schema = responseSchema
                    };
                }

                responses.Add("500", response);
            }
        }