Exemplo n.º 1
0
        /// <summary>
        /// Generate the Publish operation of an AsyncApi Channel for the given method.
        /// </summary>
        private Operation GeneratePublishOperation(MethodInfo method, ISchemaRepository schemaRepository)
        {
            var publishOperationAttribute = method.GetCustomAttribute <PublishOperationAttribute>();

            if (publishOperationAttribute == null)
            {
                // Happens when a Channel has a Subscribe operation instead of a Publish operation.
                return(null);
            }

            var publish = new Operation
            {
                OperationId = publishOperationAttribute.OperationId ?? method.Name,
                Summary     = publishOperationAttribute.Summary ?? method.GetXmlDocsSummary(),
                Description = publishOperationAttribute.Description ?? (method.GetXmlDocsRemarks() != "" ? method.GetXmlDocsRemarks() : null),
                Message     = GenerateMessage(method, publishOperationAttribute, schemaRepository),
            };

            var filterContext = new PublishOperationFilterContext(method, schemaRepository, publishOperationAttribute);

            foreach (var filter in _options.PublishOperationFilters)
            {
                filter.Apply(publish, filterContext);
            }

            return(publish);
        }
Exemplo n.º 2
0
 public void Apply(Operation publishOperation, PublishOperationFilterContext context)
 {
     publishOperation.Traits.Add(new OperationTraitReference("exampleTrait"));
 }