Beispiel #1
0
        private async Task <SigSpecOperation> GenerateOperationAsync(Type type, MethodInfo method, JsonSchemaGenerator generator, SigSpecSchemaResolver resolver)
        {
            var operation = new SigSpecOperation();

            operation.Description = await type.GetXmlSummaryAsync();

            foreach (var arg in method.GetParameters())
            {
                var parameter = await generator.GenerateWithReferenceAndNullabilityAsync <SigSpecParameter>(
                    arg.ParameterType,
                    arg.GetCustomAttributes(),
                    resolver,
                    async (p, s) =>
                {
                    p.Description = await arg.GetXmlDocumentationAsync();
                });

                operation.Parameters[arg.Name] = parameter;
            }

            return(operation);
        }
Beispiel #2
0
        private async Task <SigSpecOperation> GenerateOperationAsync(Type type, MethodInfo method, JsonSchemaGenerator generator, SigSpecSchemaResolver resolver, SigSpecOperationType operationType)
        {
            var operation = new SigSpecOperation
            {
                Description = await type.GetXmlSummaryAsync(),
                Type        = operationType
            };

            foreach (var arg in method.GetParameters())
            {
                var parameter = await generator.GenerateWithReferenceAndNullabilityAsync <SigSpecParameter>(
                    arg.ParameterType, arg.GetCustomAttributes(), resolver, async (p, s) =>
                {
                    p.Description = await arg.GetXmlDocumentationAsync();
                });

                operation.Parameters[arg.Name] = parameter;
            }

            var returnType =
                operationType == SigSpecOperationType.Observable
                    ? method.ReturnType.GetGenericTypeArguments().First()
                : method.ReturnType == typeof(Task)
                    ? null
                : method.ReturnType.IsGenericType && method.ReturnType.BaseType == typeof(Task)
                    ? method.ReturnType.GetGenericTypeArguments().First()
                    : method.ReturnType;

            operation.ReturnType = returnType == null ? null : await generator.GenerateWithReferenceAndNullabilityAsync <JsonSchema4>(
                returnType, null, resolver, async (p, s) =>
            {
                p.Description = await method.ReturnType.GetXmlSummaryAsync();
            });

            return(operation);
        }
Beispiel #3
0
        private async Task <SigSpecOperation> GenerateOperationAsync(Type type, MethodInfo method, JsonSchemaGenerator generator, SigSpecSchemaResolver resolver, SigSpecOperationType operationType)
        {
            var operation = new SigSpecOperation
            {
                Description = method.GetXmlDocsSummary(),
                Type        = operationType
            };

            foreach (var arg in method.GetParameters())
            {
                var parameter = generator.GenerateWithReferenceAndNullability <SigSpecParameter>(
                    arg.ParameterType.ToContextualType(), arg.ParameterType.ToContextualType().IsNullableType, resolver, (p, s) =>
                {
                    p.Description = arg.GetXmlDocs();
                });

                operation.Parameters[arg.Name] = parameter;
            }

            var returnType =
                operationType == SigSpecOperationType.Observable
                    ? method.ReturnType.GetGenericArguments().First()
                : method.ReturnType == typeof(Task)
                    ? null
                : method.ReturnType.IsGenericType && method.ReturnType.BaseType == typeof(Task)
                    ? method.ReturnType.GetGenericArguments().First()
                    : method.ReturnType;

            operation.ReturnType = returnType == null ? null : generator.GenerateWithReferenceAndNullability <JsonSchema>(
                returnType.ToContextualType(), returnType.ToContextualType().IsNullableType, resolver, async(p, s) =>
            {
                p.Description = method.ReturnType.GetXmlDocsSummary();
            });

            return(operation);
        }