Beispiel #1
0
        private static IMessage GenerateMessageFromType(Type payloadType, AsyncApiSchemaResolver schemaResolver, JsonSchemaGenerator jsonSchemaGenerator)
        {
            if (payloadType == null)
            {
                return(null);
            }

            var message = new Message
            {
                Payload = jsonSchemaGenerator.Generate(payloadType, schemaResolver),
            };

            message.Name = message.Payload.Id;

            return(schemaResolver.GetMessageOrReference(message));
        }
Beispiel #2
0
        private static IMessage GenerateMessageFromAttribute(MessageAttribute messageAttribute, AsyncApiSchemaResolver schemaResolver, JsonSchemaGenerator jsonSchemaGenerator)
        {
            if (messageAttribute?.PayloadType == null)
            {
                return(null);
            }

            var message = new Message
            {
                Payload     = jsonSchemaGenerator.Generate(messageAttribute.PayloadType, schemaResolver),
                Title       = messageAttribute.Title,
                Summary     = messageAttribute.Summary,
                Description = messageAttribute.Description,
                Bindings    = messageAttribute.BindingsRef != null ? new MessageBindingsReference(messageAttribute.BindingsRef) : null,
            };

            message.Name = messageAttribute.Name ?? message.Payload.ActualSchema.Id;

            return(schemaResolver.GetMessageOrReference(message));
        }