private static void ApplyResponseAttribute(
            Operation operation,
            OperationFilterContext context,
            SwaggerResponseAttribute attribute)
        {
            var statusCode = attribute.StatusCode.ToString();

            operation.Responses[statusCode] = new Response
            {
                Description = attribute.Description ?? InferDescriptionFrom(statusCode),
                Schema      = (attribute.Type == null)
                    ? null
                    : context.SchemaRegistry.GetOrRegister(attribute.Type)
            };
        }
コード例 #2
0
        private static void ApplyResponseAttribute(
            Operation operation,
            OperationFilterContext context,
            SwaggerResponseAttribute attribute)
        {
            var statusCode = attribute.StatusCode.ToString();

            operation.Responses[statusCode] = new Response
            {
                Description = attribute.Description ?? InferDescriptionFrom(statusCode),
                Schema = (attribute.Type == null)
                    ? null
                    : context.SchemaRegistry.GetOrRegister(attribute.Type)
            };
        }
コード例 #3
0
        private static void ApplyAttribute(Operation operation, OperationFilterContext context, SwaggerResponseAttribute attribute)
        {
            var      key = attribute.StatusCode.ToString();
            Response response;

            if (!operation.Responses.TryGetValue(key, out response))
            {
                response = new Response();
            }

            response.Description = attribute.Description;
            if (attribute.Type != null && attribute.Type != typeof(void))
            {
                response.Schema = context.SchemaRegistry.GetOrRegister(attribute.Type);
            }

            operation.Responses[key] = response;
        }