From deac589a0a4b34ecf4a8d9ae70abd707144f770b Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Tue, 17 Dec 2024 12:32:48 +0100 Subject: [PATCH 01/21] feat(Solution): Implemented the AsyncAPI Specification version 3.0.0 Closes #31 Signed-off-by: Charles d'Avernas --- samples/StreetLightsApi/Program.cs | 4 +- .../Models/AsyncApiDocumentViewModel.cs | 10 +- .../Models/BindingDefinitionViewModel.cs | 4 +- .../Models/ChannelDefinitionViewModel.cs | 8 +- .../CorrelationIdDefinitionViewModel.cs | 2 +- .../Models/MessageDefinitionViewModel.cs | 8 +- .../Models/OAuthFlowDefinitionViewModel.cs | 4 +- .../Models/OperationDefinitionViewModel.cs | 14 +- .../Models/SchemaViewModel.cs | 2 +- .../Models/SecurityRequirementViewModel.cs | 2 +- .../SecuritySchemeDefinitionViewModel.cs | 10 +- .../Models/ServerDefinitionViewModel.cs | 10 +- .../Pages/AsyncApi.cshtml | 4 +- .../Pages/AsyncApi.cshtml.cs | 18 +-- .../Pages/Shared/_Operation.cshtml | 6 +- .../AsyncApiDocumentServingMiddleware.cs | 20 +-- .../AsyncApiDocumentServingOptions.cs | 4 +- ...syncApiDocumentServingOptionsExtensions.cs | 12 +- .../CloudEventMessageDefinitionBuilder.cs | 2 +- .../Extensions/IChannelBuilderExtensions.cs | 4 +- .../ICloudEventMessageDefinitionBuilder.cs | 32 ++-- .../{v2 => }/ApiKeyLocation.cs | 2 +- .../AsyncApiDocumentFormat.cs | 3 - .../{v2 => }/AsyncApiProtocol.cs | 6 +- .../AsyncApiSpecVersion.cs | 5 + .../Attributes/AsyncApiAttribute.cs | 22 +-- .../Attributes/ChannelAttribute.cs | 12 +- .../Attributes/MessageAttribute.cs | 12 +- .../Attributes/OperationAttribute.cs | 24 +-- .../Attributes/PublishOperationAttribute.cs | 8 +- .../Attributes/SubscribeOperationAttribute.cs | 8 +- .../Attributes/TagAttribute.cs | 2 +- .../Bindings/Amqp/AmqpBindingDefinition.cs | 5 +- .../Amqp/AmqpChannelBindingDefinition.cs | 4 +- .../{v2 => }/Bindings/Amqp/AmqpChannelType.cs | 2 +- .../Bindings/Amqp/AmqpDeliveryMode.cs | 2 +- .../Bindings/Amqp/AmqpExchangeDefinition.cs | 2 +- .../Bindings/Amqp/AmqpExchangeType.cs | 2 +- .../Amqp/AmqpMessageBindingDefinition.cs | 4 +- .../Amqp/AmqpOperationBindingDefinition.cs | 4 +- .../Bindings/Amqp/AmqpQueueDefinition.cs | 2 +- .../Amqp/AmqpServerBindingDefinition.cs | 4 +- .../AmqpV1/AmqpV1BindingDefinition.cs | 18 ++- .../AmqpV1/AmqpV1ChannelBindingDefinition.cs | 4 +- .../AmqpV1/AmqpV1MessageBindingDefinition.cs | 4 +- .../AmqpV1OperationBindingDefinition.cs | 4 +- .../AmqpV1/AmqpV1ServerBindingDefinition.cs | 4 +- .../AnypointMQ/AnypointMQBindingDefinition.cs | 18 ++- .../AnypointMQChannelBindingDefinition.cs | 4 +- .../AnypointMQMessageBindingDefinition.cs | 3 +- .../AnypointMQOperationBindingDefinition.cs | 4 +- .../AnypointMQServerBindingDefinition.cs | 4 +- .../Bindings/AnypointMQ/JmsDestinationType.cs | 2 +- .../Bindings/BindingDefinitionCollection.cs | 2 +- .../ChannelBindingDefinitionCollection.cs | 83 +++++------ .../GooglePubSubBindingDefinition.cs | 18 ++- .../GooglePubSubChannelBindingDefinition.cs | 4 +- .../GooglePubSubMessageBindingDefinition.cs | 4 +- .../GooglePubSubMessageEncoding.cs | 2 +- ...glePubSubMessageStoragePolicyDefinition.cs | 2 +- .../GooglePubSubOperationBindingDefinition.cs | 3 +- .../GooglePubSubSchemaDefinition.cs | 2 +- .../GooglePubSubSchemaSettings.cs | 16 +- .../GooglePubSubServerBindingDefinition.cs | 4 +- .../Bindings/Http/HttpBindingDefinition.cs | 5 +- .../Bindings/Http/HttpBindingOperationType.cs | 2 +- .../Http/HttpChannelBindingDefinition.cs | 4 +- .../Http/HttpMessageBindingDefinition.cs | 4 +- .../{v2 => }/Bindings/Http/HttpMethod.cs | 2 +- .../Http/HttpOperationBindingDefinition.cs | 3 +- .../Http/HttpServerBindingDefinition.cs | 4 +- .../{v2 => }/Bindings/IBindingDefinition.cs | 2 +- .../Bindings/IBindingDefinitionCollection.cs | 4 +- .../Bindings/IChannelBindingDefinition.cs | 16 +- .../Bindings/IMessageBindingDefinition.cs | 16 +- .../Bindings/IOperationBindingDefinition.cs | 16 +- .../Bindings/IServerBindingDefinition.cs | 16 +- .../Bindings/IbmMQ/IbmMQBindingDefinition.cs | 18 ++- .../IbmMQ/IbmMQChannelBindingDefinition.cs | 3 +- .../Bindings/IbmMQ/IbmMQDestinationType.cs | 2 +- .../IbmMQ/IbmMQMessageBindingDefinition.cs | 4 +- .../Bindings/IbmMQ/IbmMQMessageType.cs | 2 +- .../IbmMQ/IbmMQOperationBindingDefinition.cs | 4 +- .../Bindings/IbmMQ/IbmMQQueueDefinition.cs | 2 +- .../IbmMQ/IbmMQServerBindingDefinition.cs | 4 +- .../Bindings/IbmMQ/IbmMQTopicDefinition.cs | 2 +- .../Bindings/Jms/JmsBindingDefinition.cs | 18 ++- .../Jms/JmsChannelBindingDefinition.cs | 4 +- .../Bindings/Jms/JmsDestinationType.cs | 2 +- .../Jms/JmsMessageBindingDefinition.cs | 3 +- .../Jms/JmsOperationBindingDefinition.cs | 3 +- .../Jms/JmsServerBindingDefinition.cs | 3 +- .../Bindings/Kafka/KafkaBindingDefinition.cs | 18 ++- .../Kafka/KafkaChannelBindingDefinition.cs | 4 +- .../Kafka/KafkaMessageBindingDefinition.cs | 3 +- .../Kafka/KafkaOperationBindingDefinition.cs | 3 +- .../Kafka/KafkaServerBindingDefinition.cs | 4 +- .../Mercure/MercureBindingDefinition.cs | 18 ++- .../MercureChannelBindingDefinition.cs | 4 +- .../MercureMessageBindingDefinition.cs | 4 +- .../MercureOperationBindingDefinition.cs | 4 +- .../Mercure/MercureServerBindingDefinition.cs | 4 +- .../MessageBindingDefinitionCollection.cs | 83 +++++------ .../Bindings/Mqtt/MqttBindingDefinition.cs | 5 +- .../Mqtt/MqttChannelBindingDefinition.cs | 4 +- .../Bindings/Mqtt/MqttLastWillDefinition.cs | 2 +- .../Mqtt/MqttMessageBindingDefinition.cs | 4 +- .../Mqtt/MqttOperationBindingDefinition.cs | 4 +- .../{v2 => }/Bindings/Mqtt/MqttQoSLevel.cs | 2 +- .../Mqtt/MqttServerBindingDefinition.cs | 4 +- .../MqttV5/MqttV5BindingDefinition.cs | 5 +- .../MqttV5/MqttV5ChannelBindingDefinition.cs | 4 +- .../MqttV5/MqttV5MessageBindingDefinition.cs | 4 +- .../MqttV5OperationBindingDefinition.cs | 4 +- .../MqttV5/MqttV5ServerBindingDefinition.cs | 4 +- .../Bindings/Nats/NatsBindingDefinition.cs | 5 +- .../Nats/NatsChannelBindingDefinition.cs | 4 +- .../Nats/NatsMessageBindingDefinition.cs | 4 +- .../Nats/NatsOperationBindingDefinition.cs | 4 +- .../Nats/NatsServerBindingDefinition.cs | 4 +- .../OperationBindingDefinitionCollection.cs | 83 +++++------ .../Pulsar/PulsarBindingDefinition.cs | 18 ++- .../Pulsar/PulsarChannelBindingDefinition.cs | 4 +- .../Pulsar/PulsarMessageBindingDefinition.cs | 4 +- .../PulsarOperationBindingDefinition.cs | 4 +- .../Pulsar/PulsarRetentionPolicyDefinition.cs | 2 +- .../Pulsar/PulsarServerBindingDefinition.cs | 4 +- .../Bindings/Pulsar/PulsarTopicTypes.cs | 2 +- .../Bindings/Redis/RedisBindingDefinition.cs | 5 +- .../Redis/RedisChannelBindingDefinition.cs | 4 +- .../Redis/RedisMessageBindingDefinition.cs | 4 +- .../Redis/RedisOperationBindingDefinition.cs | 4 +- .../Redis/RedisServerBindingDefinition.cs | 4 +- .../ServerBindingDefinitionCollection.cs | 83 +++++------ .../Bindings/Sns/SnsBackoffAlgorithm.cs | 2 +- .../Bindings/Sns/SnsBindingDefinition.cs | 18 ++- .../Sns/SnsChannelBindingDefinition.cs | 4 +- .../{v2 => }/Bindings/Sns/SnsConsumer.cs | 2 +- .../Bindings/Sns/SnsConsumerDeliveryPolicy.cs | 16 +- .../Sns/SnsConsumerFilterPolicyScope.cs | 2 +- .../Bindings/Sns/SnsConsumerRedrivePolicy.cs | 2 +- .../{v2 => }/Bindings/Sns/SnsIdentifier.cs | 2 +- .../Sns/SnsMessageBindingDefinition.cs | 4 +- .../Sns/SnsOperationBindingDefinition.cs | 4 +- .../{v2 => }/Bindings/Sns/SnsProtocol.cs | 2 +- .../Sns/SnsServerBindingDefinition.cs | 4 +- .../Sns/SnsTopicOrderingDefinition.cs | 2 +- .../Bindings/Sns/SnsTopicOrderingType.cs | 2 +- .../Sns/SnsTopicSecurityPolicyDefinition.cs | 2 +- .../SnsTopicSecurityStatementDefinition.cs | 2 +- .../Sns/SnsTopicSecurityStatementEffect.cs | 2 +- .../Solace/SolaceBindingDefinition.cs | 18 ++- .../Solace/SolaceChannelBindingDefinition.cs | 4 +- .../Bindings/Solace/SolaceDeliveryMode.cs | 2 +- .../Solace/SolaceDestinationDefinition.cs | 16 +- .../Bindings/Solace/SolaceDestinationType.cs | 2 +- .../Solace/SolaceMessageBindingDefinition.cs | 4 +- .../SolaceOperationBindingDefinition.cs | 4 +- .../Bindings/Solace/SolaceQueueAccessType.cs | 2 +- .../Bindings/Solace/SolaceQueueDefinition.cs | 16 +- .../Solace/SolaceServerBindingDefinition.cs | 4 +- .../Bindings/Solace/SolaceTopicDefinition.cs | 2 +- .../Bindings/Sqs/SqsBindingDefinition.cs | 50 +++++++ .../Sqs/SqsChannelBindingDefinition.cs | 4 +- .../Bindings/Sqs/SqsDeduplicationScope.cs | 2 +- .../Bindings/Sqs/SqsFifoThroughputLimit.cs | 2 +- .../{v2 => }/Bindings/Sqs/SqsIdentifier.cs | 2 +- .../Sqs/SqsMessageBindingDefinition.cs | 4 +- .../Sqs/SqsOperationBindingDefinition.cs | 4 +- .../Bindings/Sqs/SqsQueueDefinition.cs | 16 +- .../Sqs/SqsQueueRedrivePolicyDefinition.cs | 18 ++- .../Sqs/SqsQueueSecurityPolicyDefinition.cs | 2 +- .../Sqs/SqsServerBindingDefinition.cs | 4 +- .../SqsTopicSecurityStatementDefinition.cs | 2 +- .../Sqs/SqsTopicSecurityStatementEffect.cs | 2 +- .../Bindings/Stomp/StompBindingDefinition.cs | 18 ++- .../Stomp/StompChannelBindingDefinition.cs | 4 +- .../Stomp/StompMessageBindingDefinition.cs | 4 +- .../Stomp/StompOperationBindingDefinition.cs | 4 +- .../Stomp/StompServerBindingDefinition.cs | 4 +- .../WebSockets/WsBindingDefinition.cs | 5 +- .../WebSockets/WsChannelBindingDefinition.cs | 6 +- .../WebSockets/WsMessageBindingDefinition.cs | 4 +- .../WsOperationBindingDefinition.cs | 4 +- .../WebSockets/WsServerBindingDefinition.cs | 4 +- .../{v2 => }/ContactDefinition.cs | 2 +- .../{v2 => }/CorrelationIdDefinition.cs | 2 +- .../ExternalDocumentationDefinition.cs | 3 +- .../{v2 => }/HttpApiKeyLocation.cs | 2 +- .../{v2 => }/IReferenceable.cs | 2 +- .../{v2 => }/LicenseDefinition.cs | 2 +- .../{v2 => }/OAuthFlowDefinition.cs | 2 +- .../{v2 => }/OAuthFlowDefinitionCollection.cs | 4 +- .../ReferenceableComponentDefinition.cs | 2 +- .../{v2 => }/RuntimeExpression.cs | 2 +- .../{v2 => }/RuntimeExpressionSource.cs | 2 +- .../{v2 => }/SecuritySchemeType.cs | 5 +- ...inition.cs => ServerVariableDefinition.cs} | 5 +- .../{v2 => }/TagDefinition.cs | 3 +- src/Neuroglia.AsyncApi.Core/Usings.cs | 8 +- .../v2/{ApiInfo.cs => V2ApiInfo.cs} | 4 +- ...ncApiDocument.cs => V2AsyncApiDocument.cs} | 38 +++-- ...elDefinition.cs => V2ChannelDefinition.cs} | 74 +++++----- ....cs => V2ComponentDefinitionCollection.cs} | 25 ++-- ...geDefinition.cs => V2MessageDefinition.cs} | 8 +- ...inition.cs => V2MessageTraitDefinition.cs} | 9 +- ...Definition.cs => V2OperationDefinition.cs} | 8 +- ...ion.cs => V2OperationMessageDefinition.cs} | 16 +- ...ition.cs => V2OperationTraitDefinition.cs} | 6 +- .../{OperationType.cs => V2OperationType.cs} | 5 +- ...Definition.cs => V2ParameterDefinition.cs} | 6 +- ...ition.cs => V2SecuritySchemeDefinition.cs} | 2 +- ...verDefinition.cs => V2ServerDefinition.cs} | 10 +- src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs | 70 +++++++++ .../v3/V3AsyncApiDocument.cs | 83 +++++++++++ .../v3/V3ChannelDefinition.cs | 90 ++++++++++++ .../v3/V3ComponentDefinitionCollection.cs | 138 ++++++++++++++++++ .../v3/V3MessageDefinition.cs | 37 +++++ .../v3/V3MessageExampleDefinition.cs | 47 ++++++ .../v3/V3MessageTraitDefinition.cs | 95 ++++++++++++ .../v3/V3OperationAction.cs | 33 +++++ .../v3/V3OperationDefinition.cs | 56 +++++++ .../v3/V3OperationReplyAddressDefinition.cs | 36 +++++ .../v3/V3OperationReplyDefinition.cs | 42 ++++++ .../v3/V3OperationTraitDefinition.cs | 66 +++++++++ .../v3/V3ParameterDefinition.cs | 54 +++++++ .../V3ReferenceDefinition.cs} | 22 ++- .../v3/V3SchemaDefinition.cs | 40 +++++ .../v3/V3SecuritySchemeDefinition.cs | 82 +++++++++++ .../v3/V3ServerDefinition.cs | 101 +++++++++++++ .../IServiceCollectionExtensions.cs | 14 +- .../AsyncApiDocumentBuilder.cs | 27 ++-- .../ChannelDefinitionBuilder.cs | 26 ++-- .../Interfaces/IAsyncApiDocumentBuilder.cs | 115 ++++++++------- .../Interfaces/IChannelDefinitionBuilder.cs | 38 ++--- .../Interfaces/IMessageDefinitionBuilder.cs | 30 ++-- .../IMessageTraitDefinitionBuilder.cs | 52 +++---- .../Interfaces/IOAuthFlowDefinitionBuilder.cs | 2 - .../IOAuthFlowDefinitionCollectionBuilder.cs | 2 - .../Interfaces/IOperationDefinitionBuilder.cs | 16 +- .../IOperationTraitDefinitionBuilder.cs | 28 ++-- .../Interfaces/IParameterDefinitionBuilder.cs | 24 +-- .../Interfaces/IRuntimeExpressionBuilder.cs | 2 - .../IRuntimeExpressionFragmentBuilder.cs | 2 - .../ISecuritySchemeDefinitionBuilder.cs | 32 ++-- .../Interfaces/IServerDefinitionBuilder.cs | 31 ++-- .../Interfaces/ITagDefinitionBuilder.cs | 2 - .../Interfaces/IVariableDefinitionBuilder.cs | 18 +-- .../MessageDefinitionBuilder.cs | 10 +- .../MessageTraitBuilder.cs | 6 +- .../MessageTraitDefinitionBuilder.cs | 11 +- .../OAuthFlowDefinitionBuilder.cs | 2 - .../OAuthFlowDefinitionCollectionBuilder.cs | 2 - .../OperationDefinitionBuilder.cs | 10 +- .../OperationTraitBuilder.cs | 6 +- .../OperationTraitDefinitionBuilder.cs | 12 +- .../ParameterDefinitionBuilder.cs | 14 +- .../RuntimeExpressionBuilder.cs | 1 - .../SecuritySchemeDefinitionBuilder.cs | 16 +- .../ServerDefinitionBuilder.cs | 16 +- .../TagDefinitionBuilder.cs | 2 - .../VariableDefinitionBuilder.cs | 16 +- .../AsyncApiDocumentGenerationOptions.cs | 4 +- .../AsyncApiDocumentGenerator.cs | 24 +-- .../AsyncApiDocumentProvider.cs | 20 +-- .../AsyncApiGenerationOptions.cs | 2 +- .../Interfaces/IAsyncApiDocumentGenerator.cs | 8 +- .../Interfaces/IAsyncApiDocumentProvider.cs | 22 +-- .../IAsyncApiGenerationOptionsBuilder.cs | 4 +- .../AsyncApiDocumentReader.cs | 10 +- .../AsyncApiDocumentWriter.cs | 6 +- .../Interfaces/IAsyncApiDocumentReader.cs | 10 +- .../Interfaces/IAsyncApiDocumentWriter.cs | 14 +- .../v2/AsyncApiDocumentValidator.cs | 4 +- .../v2/ChannelValidator.cs | 4 +- .../v2/ComponentsValidator.cs | 4 +- .../v2/InfoValidator.cs | 4 +- .../v2/LicenseValidator.cs | 2 - .../v2/MessageTraitValidator.cs | 4 +- .../v2/MessageValidator.cs | 4 +- .../v2/OperationTraitValidator.cs | 4 +- .../v2/OperationValidator.cs | 4 +- .../v2/ServerValidator.cs | 4 +- .../v2/TagValidator.cs | 2 - .../AsyncApiDocumentSerializationTests.cs | 4 +- .../Cases/Core/RuntimeExpressionTests.cs | 2 - .../Cases/Fluent/FluentBuilderTests.cs | 1 - .../Services/AsyncApiDocumentFactory.cs | 10 +- 288 files changed, 2512 insertions(+), 1051 deletions(-) rename src/Neuroglia.AsyncApi.Core/{v2 => }/ApiKeyLocation.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/AsyncApiProtocol.cs (94%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Amqp/AmqpBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Amqp/AmqpChannelBindingDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Amqp/AmqpChannelType.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Amqp/AmqpDeliveryMode.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Amqp/AmqpExchangeDefinition.cs (98%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Amqp/AmqpExchangeType.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Amqp/AmqpMessageBindingDefinition.cs (94%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Amqp/AmqpOperationBindingDefinition.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Amqp/AmqpQueueDefinition.cs (98%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Amqp/AmqpServerBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/AmqpV1/AmqpV1BindingDefinition.cs (60%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/AmqpV1/AmqpV1ChannelBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/AmqpV1/AmqpV1MessageBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/AmqpV1/AmqpV1OperationBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/AmqpV1/AmqpV1ServerBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/AnypointMQ/AnypointMQBindingDefinition.cs (60%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/AnypointMQ/AnypointMQChannelBindingDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/AnypointMQ/AnypointMQMessageBindingDefinition.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/AnypointMQ/AnypointMQOperationBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/AnypointMQ/AnypointMQServerBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/AnypointMQ/JmsDestinationType.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/BindingDefinitionCollection.cs (98%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/ChannelBindingDefinitionCollection.cs (77%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/GooglePubSub/GooglePubSubBindingDefinition.cs (60%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/GooglePubSub/GooglePubSubChannelBindingDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/GooglePubSub/GooglePubSubMessageBindingDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/GooglePubSub/GooglePubSubMessageEncoding.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/GooglePubSub/GooglePubSubMessageStoragePolicyDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/GooglePubSub/GooglePubSubOperationBindingDefinition.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/GooglePubSub/GooglePubSubSchemaDefinition.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/GooglePubSub/GooglePubSubSchemaSettings.cs (76%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/GooglePubSub/GooglePubSubServerBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Http/HttpBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Http/HttpBindingOperationType.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Http/HttpChannelBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Http/HttpMessageBindingDefinition.cs (94%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Http/HttpMethod.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Http/HttpOperationBindingDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Http/HttpServerBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IBindingDefinition.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IBindingDefinitionCollection.cs (93%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IChannelBindingDefinition.cs (54%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IMessageBindingDefinition.cs (54%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IOperationBindingDefinition.cs (54%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IServerBindingDefinition.cs (53%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IbmMQ/IbmMQBindingDefinition.cs (60%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IbmMQ/IbmMQChannelBindingDefinition.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IbmMQ/IbmMQDestinationType.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IbmMQ/IbmMQMessageBindingDefinition.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IbmMQ/IbmMQMessageType.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IbmMQ/IbmMQOperationBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IbmMQ/IbmMQQueueDefinition.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IbmMQ/IbmMQServerBindingDefinition.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/IbmMQ/IbmMQTopicDefinition.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Jms/JmsBindingDefinition.cs (60%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Jms/JmsChannelBindingDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Jms/JmsDestinationType.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Jms/JmsMessageBindingDefinition.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Jms/JmsOperationBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Jms/JmsServerBindingDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Kafka/KafkaBindingDefinition.cs (60%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Kafka/KafkaChannelBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Kafka/KafkaMessageBindingDefinition.cs (94%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Kafka/KafkaOperationBindingDefinition.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Kafka/KafkaServerBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Mercure/MercureBindingDefinition.cs (60%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Mercure/MercureChannelBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Mercure/MercureMessageBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Mercure/MercureOperationBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Mercure/MercureServerBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/MessageBindingDefinitionCollection.cs (77%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Mqtt/MqttBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Mqtt/MqttChannelBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Mqtt/MqttLastWillDefinition.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Mqtt/MqttMessageBindingDefinition.cs (93%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Mqtt/MqttOperationBindingDefinition.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Mqtt/MqttQoSLevel.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Mqtt/MqttServerBindingDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/MqttV5/MqttV5BindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/MqttV5/MqttV5ChannelBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/MqttV5/MqttV5MessageBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/MqttV5/MqttV5OperationBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/MqttV5/MqttV5ServerBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Nats/NatsBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Nats/NatsChannelBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Nats/NatsMessageBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Nats/NatsOperationBindingDefinition.cs (93%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Nats/NatsServerBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/OperationBindingDefinitionCollection.cs (77%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Pulsar/PulsarBindingDefinition.cs (60%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Pulsar/PulsarChannelBindingDefinition.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Pulsar/PulsarMessageBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Pulsar/PulsarOperationBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Pulsar/PulsarRetentionPolicyDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Pulsar/PulsarServerBindingDefinition.cs (94%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Pulsar/PulsarTopicTypes.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Redis/RedisBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Redis/RedisChannelBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Redis/RedisMessageBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Redis/RedisOperationBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Redis/RedisServerBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/ServerBindingDefinitionCollection.cs (77%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsBackoffAlgorithm.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsBindingDefinition.cs (60%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsChannelBindingDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsConsumer.cs (98%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsConsumerDeliveryPolicy.cs (83%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsConsumerFilterPolicyScope.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsConsumerRedrivePolicy.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsIdentifier.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsMessageBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsOperationBindingDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsProtocol.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsServerBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsTopicOrderingDefinition.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsTopicOrderingType.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsTopicSecurityPolicyDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsTopicSecurityStatementDefinition.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sns/SnsTopicSecurityStatementEffect.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Solace/SolaceBindingDefinition.cs (60%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Solace/SolaceChannelBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Solace/SolaceDeliveryMode.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Solace/SolaceDestinationDefinition.cs (78%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Solace/SolaceDestinationType.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Solace/SolaceMessageBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Solace/SolaceOperationBindingDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Solace/SolaceQueueAccessType.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Solace/SolaceQueueDefinition.cs (78%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Solace/SolaceServerBindingDefinition.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Solace/SolaceTopicDefinition.cs (96%) create mode 100644 src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsBindingDefinition.cs rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sqs/SqsChannelBindingDefinition.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sqs/SqsDeduplicationScope.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sqs/SqsFifoThroughputLimit.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sqs/SqsIdentifier.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sqs/SqsMessageBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sqs/SqsOperationBindingDefinition.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sqs/SqsQueueDefinition.cs (89%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sqs/SqsQueueRedrivePolicyDefinition.cs (68%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sqs/SqsQueueSecurityPolicyDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sqs/SqsServerBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sqs/SqsTopicSecurityStatementDefinition.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Sqs/SqsTopicSecurityStatementEffect.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Stomp/StompBindingDefinition.cs (60%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Stomp/StompChannelBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Stomp/StompMessageBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Stomp/StompOperationBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/Stomp/StompServerBindingDefinition.cs (91%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/WebSockets/WsBindingDefinition.cs (89%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/WebSockets/WsChannelBindingDefinition.cs (94%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/WebSockets/WsMessageBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/WebSockets/WsOperationBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/Bindings/WebSockets/WsServerBindingDefinition.cs (90%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/ContactDefinition.cs (98%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/CorrelationIdDefinition.cs (98%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/ExternalDocumentationDefinition.cs (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/HttpApiKeyLocation.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/IReferenceable.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/LicenseDefinition.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/OAuthFlowDefinition.cs (98%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/OAuthFlowDefinitionCollection.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/ReferenceableComponentDefinition.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/RuntimeExpression.cs (99%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/RuntimeExpressionSource.cs (97%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/SecuritySchemeType.cs (96%) rename src/Neuroglia.AsyncApi.Core/{v2/VariableDefinition.cs => ServerVariableDefinition.cs} (95%) rename src/Neuroglia.AsyncApi.Core/{v2 => }/TagDefinition.cs (96%) rename src/Neuroglia.AsyncApi.Core/v2/{ApiInfo.cs => V2ApiInfo.cs} (97%) rename src/Neuroglia.AsyncApi.Core/v2/{AsyncApiDocument.cs => V2AsyncApiDocument.cs} (77%) rename src/Neuroglia.AsyncApi.Core/v2/{ChannelDefinition.cs => V2ChannelDefinition.cs} (61%) rename src/Neuroglia.AsyncApi.Core/v2/{ComponentDefinitionCollection.cs => V2ComponentDefinitionCollection.cs} (84%) rename src/Neuroglia.AsyncApi.Core/v2/{MessageDefinition.cs => V2MessageDefinition.cs} (82%) rename src/Neuroglia.AsyncApi.Core/v2/{MessageTraitDefinition.cs => V2MessageTraitDefinition.cs} (94%) rename src/Neuroglia.AsyncApi.Core/v2/{OperationDefinition.cs => V2OperationDefinition.cs} (86%) rename src/Neuroglia.AsyncApi.Core/v2/{OperationMessageDefinition.cs => V2OperationMessageDefinition.cs} (72%) rename src/Neuroglia.AsyncApi.Core/v2/{OperationTraitDefinition.cs => V2OperationTraitDefinition.cs} (93%) rename src/Neuroglia.AsyncApi.Core/v2/{OperationType.cs => V2OperationType.cs} (91%) rename src/Neuroglia.AsyncApi.Core/v2/{ParameterDefinition.cs => V2ParameterDefinition.cs} (94%) rename src/Neuroglia.AsyncApi.Core/v2/{SecuritySchemeDefinition.cs => V2SecuritySchemeDefinition.cs} (98%) rename src/Neuroglia.AsyncApi.Core/v2/{ServerDefinition.cs => V2ServerDefinition.cs} (93%) create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3ComponentDefinitionCollection.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3MessageDefinition.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3MessageExampleDefinition.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3MessageTraitDefinition.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3OperationAction.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3OperationDefinition.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3OperationReplyAddressDefinition.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3OperationReplyDefinition.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3OperationTraitDefinition.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3ParameterDefinition.cs rename src/Neuroglia.AsyncApi.Core/{v2/Bindings/Sqs/SqsBindingDefinition.cs => v3/V3ReferenceDefinition.cs} (60%) create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3SchemaDefinition.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3SecuritySchemeDefinition.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3ServerDefinition.cs diff --git a/samples/StreetLightsApi/Program.cs b/samples/StreetLightsApi/Program.cs index 22717c1..392e6b5 100644 --- a/samples/StreetLightsApi/Program.cs +++ b/samples/StreetLightsApi/Program.cs @@ -13,7 +13,7 @@ using Json.Schema; using Neuroglia.AsyncApi; -using Neuroglia.AsyncApi.v2; +using Neuroglia.AsyncApi.Bindings.Http; using Neuroglia.AsyncApi.v2.Bindings.Http; using Neuroglia.AsyncApi.v2.Bindings.Mqtt; using Neuroglia.Data.Schemas.Json; @@ -69,7 +69,7 @@ .WithSubscribeOperation(operation => operation .WithOperationId("ObserveCloudEvents") .WithDescription("Observes cloud events published by the StreetLightsApi") - .WithBinding(new HttpOperationBindingDefinition() { Method = Neuroglia.AsyncApi.v2.Bindings.Http.HttpMethod.POST, Type = HttpBindingOperationType.Response }) + .WithBinding(new HttpOperationBindingDefinition() { Method = Neuroglia.AsyncApi.Bindings.Http.HttpMethod.POST, Type = HttpBindingOperationType.Response }) .WithMessages ( message => message diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/AsyncApiDocumentViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/AsyncApiDocumentViewModel.cs index 3cb0b8b..c13e481 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/AsyncApiDocumentViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/AsyncApiDocumentViewModel.cs @@ -14,7 +14,7 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; /// -/// Holds the data used to render an view +/// Holds the data used to render an view /// public record AsyncApiDocumentViewModel { @@ -22,12 +22,12 @@ public record AsyncApiDocumentViewModel /// /// Initializes a new /// - /// The to render the view for - public AsyncApiDocumentViewModel(AsyncApiDocument document) => this.Document = document; + /// The to render the view for + public AsyncApiDocumentViewModel(V2AsyncApiDocument document) => this.Document = document; /// - /// Gets the to render the view for + /// Gets the to render the view for /// - public AsyncApiDocument Document { get; } + public V2AsyncApiDocument Document { get; } } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/BindingDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/BindingDefinitionViewModel.cs index adba399..1fa7ba5 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/BindingDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/BindingDefinitionViewModel.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; @@ -23,7 +23,7 @@ public record BindingDefinitionViewModel { /// - public BindingDefinitionViewModel(AsyncApiDocument document, IBindingDefinition binding, string parentRef) : base(document) { this.Binding = binding; this.ParentRef = parentRef; } + public BindingDefinitionViewModel(V2AsyncApiDocument document, IBindingDefinition binding, string parentRef) : base(document) { this.Binding = binding; this.ParentRef = parentRef; } /// /// Gets the to render diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ChannelDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ChannelDefinitionViewModel.cs index f6a1f41..f406c9d 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ChannelDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ChannelDefinitionViewModel.cs @@ -14,18 +14,18 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; /// -/// Holds the data used to render an view +/// Holds the data used to render an view /// public record ChannelDefinitionViewModel : AsyncApiDocumentViewModel { /// - public ChannelDefinitionViewModel(AsyncApiDocument document, ChannelDefinition channel) : base(document) => this.Channel = channel; + public ChannelDefinitionViewModel(V2AsyncApiDocument document, V2ChannelDefinition channel) : base(document) => this.Channel = channel; /// - /// Gets the to render + /// Gets the to render /// - public ChannelDefinition Channel { get; } + public V2ChannelDefinition Channel { get; } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs index efeda28..da55320 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs @@ -21,7 +21,7 @@ public record CorrelationIdDefinitionViewModel { /// - public CorrelationIdDefinitionViewModel(AsyncApiDocument document, CorrelationIdDefinition correlationId) : base(document) { this.CorrelationId = correlationId; } + public CorrelationIdDefinitionViewModel(V2AsyncApiDocument document, CorrelationIdDefinition correlationId) : base(document) { this.CorrelationId = correlationId; } /// /// Gets the to render diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/MessageDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/MessageDefinitionViewModel.cs index 8fef8e9..b601cd1 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/MessageDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/MessageDefinitionViewModel.cs @@ -14,14 +14,14 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; /// -/// Holds the data used to render a view +/// Holds the data used to render a view /// public record MessageDefinitionViewModel : AsyncApiDocumentViewModel { /// - public MessageDefinitionViewModel(AsyncApiDocument document, int index, string operationRef, MessageDefinition definition) + public MessageDefinitionViewModel(V2AsyncApiDocument document, int index, string operationRef, V2MessageDefinition definition) : base(document) { this.Index = index; @@ -40,8 +40,8 @@ public MessageDefinitionViewModel(AsyncApiDocument document, int index, string o public string OperationRef { get; } /// - /// Gets the to render + /// Gets the to render /// - public MessageDefinition Definition { get; } + public V2MessageDefinition Definition { get; } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs index b175ae6..ef97b89 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; /// @@ -23,7 +21,7 @@ public record OAuthFlowDefinitionViewModel { /// - public OAuthFlowDefinitionViewModel(AsyncApiDocument document, string parentRef, string flowType, OAuthFlowDefinition flow) : base(document) { this.ParentRef = parentRef; this.FlowType = flowType; this.Flow = flow; } + public OAuthFlowDefinitionViewModel(V2AsyncApiDocument document, string parentRef, string flowType, OAuthFlowDefinition flow) : base(document) { this.ParentRef = parentRef; this.FlowType = flowType; this.Flow = flow; } /// /// Gets a reference to the 's parent component diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OperationDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OperationDefinitionViewModel.cs index da8ed96..bd6e279 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OperationDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OperationDefinitionViewModel.cs @@ -14,28 +14,28 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; /// -/// Holds the data used to render a view +/// Holds the data used to render a view /// public record OperationDefinitionViewModel : AsyncApiDocumentViewModel { /// - public OperationDefinitionViewModel(AsyncApiDocument document, string channelKey, OperationType operationType, OperationDefinition operation) : base(document) { this.ChannelKey = channelKey; this.OperationType = operationType; this.Operation = operation; } + public OperationDefinitionViewModel(V2AsyncApiDocument document, string channelKey, V2OperationType operationType, V2OperationDefinition operation) : base(document) { this.ChannelKey = channelKey; this.OperationType = operationType; this.Operation = operation; } /// - /// Gets the key of the the to render belongs to + /// Gets the key of the the to render belongs to /// public string ChannelKey { get; } /// - /// Gets the type of the to render + /// Gets the type of the to render /// - public OperationType OperationType { get; } + public V2OperationType OperationType { get; } /// - /// Gets the to render + /// Gets the to render /// - public OperationDefinition Operation { get; } + public V2OperationDefinition Operation { get; } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs index f58fdcd..2fb9b8e 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs @@ -21,7 +21,7 @@ public record SchemaViewModel { /// - public SchemaViewModel(AsyncApiDocument document, JsonSchema schema) : base(document) => this.Schema = schema; + public SchemaViewModel(V2AsyncApiDocument document, JsonSchema schema) : base(document) => this.Schema = schema; /// /// Gets the to render diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs index 28d8709..c2968ec 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs @@ -21,7 +21,7 @@ public record SecurityRequirementViewModel { /// - public SecurityRequirementViewModel(AsyncApiDocument document, string parentRef, string key, object? requirement) : base(document) { this.ParentRef = parentRef; this.Key = key; this.Requirement = requirement; } + public SecurityRequirementViewModel(V2AsyncApiDocument document, string parentRef, string key, object? requirement) : base(document) { this.ParentRef = parentRef; this.Key = key; this.Requirement = requirement; } /// /// Gets a reference to the requirement's parent component diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs index 475ca44..b481904 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs @@ -14,23 +14,23 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; /// -/// Holds the data used to render a view +/// Holds the data used to render a view /// public record SecuritySchemeDefinitionViewModel : AsyncApiDocumentViewModel { /// - public SecuritySchemeDefinitionViewModel(AsyncApiDocument document, string parentRef, SecuritySchemeDefinition scheme) : base(document) { this.ParentRef = parentRef; this.Scheme = scheme; } + public SecuritySchemeDefinitionViewModel(V2AsyncApiDocument document, string parentRef, V2SecuritySchemeDefinition scheme) : base(document) { this.ParentRef = parentRef; this.Scheme = scheme; } /// - /// Gets a reference to the parent component of the to render + /// Gets a reference to the parent component of the to render /// public string ParentRef { get; } /// - /// Gets the to render + /// Gets the to render /// - public SecuritySchemeDefinition Scheme { get; } + public V2SecuritySchemeDefinition Scheme { get; } } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ServerDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ServerDefinitionViewModel.cs index caa2411..dcd76cc 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ServerDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ServerDefinitionViewModel.cs @@ -14,23 +14,23 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; /// -/// Holds the data used to render a view +/// Holds the data used to render a view /// public record ServerDefinitionViewModel : AsyncApiDocumentViewModel { /// - public ServerDefinitionViewModel(AsyncApiDocument document, string key, ServerDefinition server) : base(document) { this.Key = key; this.Server = server; } + public ServerDefinitionViewModel(V2AsyncApiDocument document, string key, V2ServerDefinition server) : base(document) { this.Key = key; this.Server = server; } /// - /// Gets the key of the to render + /// Gets the key of the to render /// public string Key { get; } /// - /// Gets the to render + /// Gets the to render /// - public ServerDefinition Server { get; } + public V2ServerDefinition Server { get; } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml index d916935..3a702a9 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml @@ -80,11 +80,11 @@ { if (channel.Value.Publish != null) { - + } if (channel.Value.Subscribe != null) { - + } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml.cs index 3fb76e1..3cffa6b 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml.cs @@ -17,12 +17,12 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Pages; /// -/// Represents the model of the page used to render an +/// Represents the model of the page used to render an /// /// /// Initializes a new /// -/// The service used to access generated s +/// The service used to access generated s public class AsyncApiDocumentModel(IAsyncApiDocumentProvider documents) : PageModel { @@ -30,25 +30,25 @@ public class AsyncApiDocumentModel(IAsyncApiDocumentProvider documents) IAsyncApiDocumentProvider Documents { get; } = documents; /// - /// Gets the requested 's title + /// Gets the requested 's title /// public string? RequestedTitle { get; private set; } /// - /// Gets the requested 's version + /// Gets the requested 's version /// public string? RequestedVersion { get; private set; } /// - /// Gets the current + /// Gets the current /// - public AsyncApiDocument? Document { get; private set; } + public V2AsyncApiDocument? Document { get; private set; } /// - /// Renders the with the specified title and version + /// Renders the with the specified title and version /// - /// The title of the to render - /// The version of the to render + /// The title of the to render + /// The version of the to render public void OnGet(string title, string version) { this.RequestedTitle = title; diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Operation.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Operation.cshtml index 3d5e169..fdf14e1 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Operation.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Operation.cshtml @@ -8,9 +8,9 @@ var schema = string.IsNullOrWhiteSpace(jsonPayload) ? null : JsonSchema.FromText(jsonPayload); var operationRef = $"{operation.OperationId!.ToLowerInvariant()}-{EnumHelper.Stringify(operationType).ToLowerInvariant()}"; - var badgeColor = operationType == OperationType.Publish ? "info" : "info"; - var badgeTooltip = operationType == OperationType.Publish ? "An operation used to publish a message to the specified channel." : "An operation used to subscribe to messages from the specified channel."; - var badgeText = operationType == OperationType.Publish ? "PUB" : "SUB"; + var badgeColor = operationType == V2OperationType.Publish ? "info" : "info"; + var badgeTooltip = operationType == V2OperationType.Publish ? "An operation used to publish a message to the specified channel." : "An operation used to subscribe to messages from the specified channel."; + var badgeText = operationType == V2OperationType.Publish ? "PUB" : "SUB"; }
diff --git a/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingMiddleware.cs b/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingMiddleware.cs index 91f9ae3..cd6a436 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingMiddleware.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingMiddleware.cs @@ -20,14 +20,14 @@ namespace Neuroglia.AsyncApi; /// -/// Represents the middleware used to serve s +/// Represents the middleware used to serve s /// /// /// Initializes a new /// /// The service used to access the current -/// The service used to provide s -/// The service used to write s +/// The service used to provide s +/// The service used to write s /// The the next in the pipeline public class AsyncApiDocumentServingMiddleware(IOptions options, IAsyncApiDocumentProvider documentProvider, IAsyncApiDocumentWriter documentWriter, RequestDelegate next) { @@ -38,12 +38,12 @@ public class AsyncApiDocumentServingMiddleware(IOptions - /// Gets the service used to provide s + /// Gets the service used to provide s ///
protected virtual IAsyncApiDocumentProvider DocumentProvider { get; } = documentProvider; /// - /// Gets the service used to write s + /// Gets the service used to write s /// protected virtual IAsyncApiDocumentWriter DocumentWriter { get; } = documentWriter; @@ -53,9 +53,9 @@ public class AsyncApiDocumentServingMiddleware(IOptions - /// Gets a route/ mapping of the routes rendered based on the configured template for all available s + /// Gets a route/ mapping of the routes rendered based on the configured template for all available s ///
- protected virtual Dictionary DocumentRoutes { get; } = documentProvider.ToDictionary(d => d, options.Value.GenerateRoutesFor).SelectMany(kvp => kvp.Value.Select(r => new KeyValuePair(r, kvp.Key))).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); + protected virtual Dictionary DocumentRoutes { get; } = documentProvider.ToDictionary(d => d, options.Value.GenerateRoutesFor).SelectMany(kvp => kvp.Value.Select(r => new KeyValuePair(r, kvp.Key))).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); /// /// Invokes the @@ -108,11 +108,11 @@ protected virtual byte[] RenderAsyncApiDocumentList() } /// - /// Renders the Async API document version list for the specified s + /// Renders the Async API document version list for the specified s /// - /// The of versions to render the list for + /// The of versions to render the list for /// The encoded html of the Async API document version list - protected virtual byte[] RenderAsyncApiDocumentVersionList(IGrouping versions) + protected virtual byte[] RenderAsyncApiDocumentVersionList(IGrouping versions) { string html = $@" {versions.Key} diff --git a/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingOptions.cs b/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingOptions.cs index 0962ec8..86849e8 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingOptions.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingOptions.cs @@ -16,13 +16,13 @@ namespace Neuroglia.AsyncApi; /// -/// Represents the options used to configure how to serve s +/// Represents the options used to configure how to serve s /// public class AsyncApiDocumentServingOptions { /// - /// Gets/sets the path prefix of s + /// Gets/sets the path prefix of s /// public virtual string PathTemplate { get; set; } = "/asyncapi/{title}.{version}.[json|yaml]"; diff --git a/src/Neuroglia.AsyncApi.AspNetCore/Extensions/AsyncApiDocumentServingOptionsExtensions.cs b/src/Neuroglia.AsyncApi.AspNetCore/Extensions/AsyncApiDocumentServingOptionsExtensions.cs index fbcdb54..3eab178 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore/Extensions/AsyncApiDocumentServingOptionsExtensions.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore/Extensions/AsyncApiDocumentServingOptionsExtensions.cs @@ -22,12 +22,12 @@ public static class AsyncApiDocumentServingOptionsExtensions { /// - /// Generates routes for the specified + /// Generates routes for the specified /// /// The current - /// The to generate the routes for + /// The to generate the routes for /// A new containing the egenerated routes - public static IEnumerable GenerateRoutesFor(this AsyncApiDocumentServingOptions options, AsyncApiDocument document) + public static IEnumerable GenerateRoutesFor(this AsyncApiDocumentServingOptions options, V2AsyncApiDocument document) { ArgumentNullException.ThrowIfNull(options); ArgumentNullException.ThrowIfNull(document); @@ -40,13 +40,13 @@ public static IEnumerable GenerateRoutesFor(this AsyncApiDocumentServing } /// - /// Generates route for the specified + /// Generates route for the specified /// /// The current - /// The to generate the route for + /// The to generate the route for /// The to generate the route for /// The generated route - public static string GenerateRouteFor(this AsyncApiDocumentServingOptions options, AsyncApiDocument document, AsyncApiDocumentFormat format) + public static string GenerateRouteFor(this AsyncApiDocumentServingOptions options, V2AsyncApiDocument document, AsyncApiDocumentFormat format) { ArgumentNullException.ThrowIfNull(options); ArgumentNullException.ThrowIfNull(document); diff --git a/src/Neuroglia.AsyncApi.CloudEvents/Extensions/CloudEventMessageDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.CloudEvents/Extensions/CloudEventMessageDefinitionBuilder.cs index b8c21e5..ea69f1e 100644 --- a/src/Neuroglia.AsyncApi.CloudEvents/Extensions/CloudEventMessageDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.CloudEvents/Extensions/CloudEventMessageDefinitionBuilder.cs @@ -141,7 +141,7 @@ public virtual ICloudEventMessageDefinitionBuilder WithExtensionAttribute(string } /// - public virtual MessageDefinition Build() + public virtual V2MessageDefinition Build() { var cloudEventSchema = new JsonSchemaBuilder().Ref(CloudEventSchemaUri).Build(); diff --git a/src/Neuroglia.AsyncApi.CloudEvents/Extensions/IChannelBuilderExtensions.cs b/src/Neuroglia.AsyncApi.CloudEvents/Extensions/IChannelBuilderExtensions.cs index 7ff1a6b..04af4ca 100644 --- a/src/Neuroglia.AsyncApi.CloudEvents/Extensions/IChannelBuilderExtensions.cs +++ b/src/Neuroglia.AsyncApi.CloudEvents/Extensions/IChannelBuilderExtensions.cs @@ -23,10 +23,10 @@ public static class IAsyncApiDocumentBuilderExtensions { /// - /// Configures the to build to use the specified + /// Configures the to build to use the specified /// /// The to configure - /// An used to setup the to use + /// An used to setup the to use /// The configured public static IOperationDefinitionBuilder WithCloudEventMessage(this IOperationDefinitionBuilder operation, Action setup) { diff --git a/src/Neuroglia.AsyncApi.CloudEvents/Extensions/ICloudEventMessageDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.CloudEvents/Extensions/ICloudEventMessageDefinitionBuilder.cs index 0723fa6..6a1192b 100644 --- a/src/Neuroglia.AsyncApi.CloudEvents/Extensions/ICloudEventMessageDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.CloudEvents/Extensions/ICloudEventMessageDefinitionBuilder.cs @@ -18,55 +18,55 @@ namespace Neuroglia.AsyncApi.CloudEvents; /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// public interface ICloudEventMessageDefinitionBuilder { /// - /// Configures the to build to use the specified spec version + /// Configures the to build to use the specified spec version /// /// The spec version to use /// The configured ICloudEventMessageDefinitionBuilder WithSpecVersion(string specVersion); /// - /// Configures the to build to use the specified source + /// Configures the to build to use the specified source /// /// The 's source /// The configured ICloudEventMessageDefinitionBuilder WithSource(Uri source); /// - /// Configures the to build to use the specified type + /// Configures the to build to use the specified type /// /// The 's type /// The configured ICloudEventMessageDefinitionBuilder WithType(string type); /// - /// Configures the to build to use the specified subject + /// Configures the to build to use the specified subject /// /// The 's subject /// The configured ICloudEventMessageDefinitionBuilder WithSubject(string? subject); /// - /// Configures the to build to use the specified data content type + /// Configures the to build to use the specified data content type /// /// The 's data content type /// The configured ICloudEventMessageDefinitionBuilder WithDataContentType(string? contentType); /// - /// Configures the to build to use the specified data + /// Configures the to build to use the specified data /// /// An that references the 's data /// The configured ICloudEventMessageDefinitionBuilder WithDataSchemaUri(Uri? schemaUri); /// - /// Configures the to build to use the specified data + /// Configures the to build to use the specified data /// /// The 's data to use /// An that references the 's data @@ -74,21 +74,21 @@ public interface ICloudEventMessageDefinitionBuilder ICloudEventMessageDefinitionBuilder WithDataSchema(JsonSchema schema, Uri? schemaUri = null); /// - /// Configures the to build to use the specified data type + /// Configures the to build to use the specified data type /// - /// The type of data transported by the to build a new for + /// The type of data transported by the to build a new for /// The configured ICloudEventMessageDefinitionBuilder WithDataOfType(Type type); /// - /// Configures the to build to use the specified data type + /// Configures the to build to use the specified data type /// - /// The type of data transported by the to build a new for + /// The type of data transported by the to build a new for /// The configured ICloudEventMessageDefinitionBuilder WithDataOfType(); /// - /// Configures the to build to use the specified extension attribute + /// Configures the to build to use the specified extension attribute /// /// The name of the extension attribute to add /// The value of the extensions attribute to add @@ -96,9 +96,9 @@ public interface ICloudEventMessageDefinitionBuilder ICloudEventMessageDefinitionBuilder WithExtensionAttribute(string name, string value); /// - /// Builds the + /// Builds the /// - /// A new - MessageDefinition Build(); + /// A new + V2MessageDefinition Build(); } diff --git a/src/Neuroglia.AsyncApi.Core/v2/ApiKeyLocation.cs b/src/Neuroglia.AsyncApi.Core/ApiKeyLocation.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/ApiKeyLocation.cs rename to src/Neuroglia.AsyncApi.Core/ApiKeyLocation.cs index f54a144..87a7178 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/ApiKeyLocation.cs +++ b/src/Neuroglia.AsyncApi.Core/ApiKeyLocation.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Exposes constants about API key locations diff --git a/src/Neuroglia.AsyncApi.Core/AsyncApiDocumentFormat.cs b/src/Neuroglia.AsyncApi.Core/AsyncApiDocumentFormat.cs index a774917..6907a9f 100644 --- a/src/Neuroglia.AsyncApi.Core/AsyncApiDocumentFormat.cs +++ b/src/Neuroglia.AsyncApi.Core/AsyncApiDocumentFormat.cs @@ -11,9 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.Serialization.Json.Converters; -using System.ComponentModel; - namespace Neuroglia.AsyncApi; /// diff --git a/src/Neuroglia.AsyncApi.Core/v2/AsyncApiProtocol.cs b/src/Neuroglia.AsyncApi.Core/AsyncApiProtocol.cs similarity index 94% rename from src/Neuroglia.AsyncApi.Core/v2/AsyncApiProtocol.cs rename to src/Neuroglia.AsyncApi.Core/AsyncApiProtocol.cs index 786ef2b..9010ef7 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/AsyncApiProtocol.cs +++ b/src/Neuroglia.AsyncApi.Core/AsyncApiProtocol.cs @@ -1,6 +1,4 @@ -// Copyright © 2021-Present Neuroglia SRL. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"), +// Licensed under the Apache License, Version 2.0 (the "License"), // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 @@ -11,7 +9,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Exposes constants about protocols officially supported by the Async API diff --git a/src/Neuroglia.AsyncApi.Core/AsyncApiSpecVersion.cs b/src/Neuroglia.AsyncApi.Core/AsyncApiSpecVersion.cs index aefb1e8..df59dfb 100644 --- a/src/Neuroglia.AsyncApi.Core/AsyncApiSpecVersion.cs +++ b/src/Neuroglia.AsyncApi.Core/AsyncApiSpecVersion.cs @@ -24,4 +24,9 @@ public static class AsyncApiSpecVersion /// public const string V2 = "2.6.0"; + /// + /// Gets the latest supported revision of the Async API Specification version 3.x.x + /// + public const string V3 = "3.0.0"; + } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/AsyncApiAttribute.cs b/src/Neuroglia.AsyncApi.Core/Attributes/AsyncApiAttribute.cs index 2f6e311..9c5e0ce 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/AsyncApiAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/Attributes/AsyncApiAttribute.cs @@ -16,7 +16,7 @@ namespace Neuroglia.AsyncApi; /// -/// Represents an used to mark a class as an Async Api to generate a new for +/// Represents an used to mark a class as an Async Api to generate a new for /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] public class AsyncApiAttribute @@ -37,52 +37,52 @@ public AsyncApiAttribute(string title, string version) } /// - /// Gets/sets the generated 's id + /// Gets/sets the generated 's id /// public virtual string? Id { get; set; } /// - /// Gets the generated 's title + /// Gets the generated 's title /// public virtual string Title { get; } /// - /// Gets the generated 's version + /// Gets the generated 's version /// public virtual string Version { get; } /// - /// Gets/sets the generated 's description + /// Gets/sets the generated 's description /// public virtual string? Description { get; set; } /// - /// Gets/sets the generated 's terms of service + /// Gets/sets the generated 's terms of service /// public virtual string? TermsOfServiceUrl { get; set; } /// - /// Gets/sets the generated 's contact name + /// Gets/sets the generated 's contact name /// public virtual string? ContactName { get; set; } /// - /// Gets/sets the generated 's contact url + /// Gets/sets the generated 's contact url /// public virtual string? ContactUrl { get; set; } /// - /// Gets/sets the generated 's contact email + /// Gets/sets the generated 's contact email /// public virtual string? ContactEmail { get; set; } /// - /// Gets/sets the generated 's license name + /// Gets/sets the generated 's license name /// public virtual string? LicenseName { get; set; } /// - /// Gets/sets the generated 's license + /// Gets/sets the generated 's license /// public virtual string? LicenseUrl { get; set; } diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/ChannelAttribute.cs b/src/Neuroglia.AsyncApi.Core/Attributes/ChannelAttribute.cs index 7a7d4ea..052edcf 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/ChannelAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/Attributes/ChannelAttribute.cs @@ -16,7 +16,7 @@ namespace Neuroglia.AsyncApi; /// -/// Represents an used to mark a class or a method as a +/// Represents an used to mark a class or a method as a /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] public class ChannelAttribute @@ -26,8 +26,8 @@ public class ChannelAttribute /// /// Initializes a new /// - /// The 's name - /// The 's description + /// The 's name + /// The 's description public ChannelAttribute(string name, string? description) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); @@ -38,16 +38,16 @@ public ChannelAttribute(string name, string? description) /// /// Initializes a new /// - /// The 's name + /// The 's name public ChannelAttribute(string name) : this(name, null) { } /// - /// Gets the 's name + /// Gets the 's name /// public virtual string Name { get; } /// - /// Gets/sets the 's description + /// Gets/sets the 's description /// public virtual string? Description { get; set; } diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/MessageAttribute.cs b/src/Neuroglia.AsyncApi.Core/Attributes/MessageAttribute.cs index 72608f1..a5b5387 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/MessageAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/Attributes/MessageAttribute.cs @@ -16,7 +16,7 @@ namespace Neuroglia.AsyncApi; /// -/// Represents an used to configure an 's +/// Represents an used to configure an 's /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)] public class MessageAttribute @@ -24,27 +24,27 @@ public class MessageAttribute { /// - /// Gets/sets the 's name + /// Gets/sets the 's name /// public virtual string? Name { get; set; } /// - /// Gets/sets the 's title + /// Gets/sets the 's title /// public virtual string? Title { get; set; } /// - /// Gets/sets the 's description + /// Gets/sets the 's description /// public virtual string? Description { get; set; } /// - /// Gets/sets the 's summary + /// Gets/sets the 's summary /// public virtual string? Summary { get; set; } /// - /// Gets/sets the 's content type + /// Gets/sets the 's content type /// public virtual string? ContentType { get; set; } diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/OperationAttribute.cs b/src/Neuroglia.AsyncApi.Core/Attributes/OperationAttribute.cs index 844629f..1f327f9 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/OperationAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/Attributes/OperationAttribute.cs @@ -16,46 +16,46 @@ namespace Neuroglia.AsyncApi; /// -/// Represents an used to mark a method as an +/// Represents an used to mark a method as an /// /// /// Initializes a new /// -/// The 's type -/// The 's message type +/// The 's type +/// The 's message type [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] -public abstract class OperationAttribute(OperationType operationType, Type? messageType) +public abstract class OperationAttribute(V2OperationType operationType, Type? messageType) : Attribute { /// /// Initializes a new /// - /// The 's type - protected OperationAttribute(OperationType operationType) : this(operationType, null) { } + /// The 's type + protected OperationAttribute(V2OperationType operationType) : this(operationType, null) { } /// - /// Gets the 's type + /// Gets the 's type /// - public virtual OperationType OperationType { get; } = operationType; + public virtual V2OperationType OperationType { get; } = operationType; /// - /// Gets the 's message type + /// Gets the 's message type /// public virtual Type? MessageType { get; } = messageType; /// - /// Gets/sets the 's operation id + /// Gets/sets the 's operation id /// public virtual string? OperationId { get; set; } /// - /// Gets/sets the 's summary + /// Gets/sets the 's summary /// public virtual string? Summary { get; set; } /// - /// Gets/sets the 's summary + /// Gets/sets the 's summary /// public virtual string? Description { get; set; } diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/PublishOperationAttribute.cs b/src/Neuroglia.AsyncApi.Core/Attributes/PublishOperationAttribute.cs index 010f952..878fe5d 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/PublishOperationAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/Attributes/PublishOperationAttribute.cs @@ -16,7 +16,7 @@ namespace Neuroglia.AsyncApi; /// -/// Represents an used to mark a method as an of type +/// Represents an used to mark a method as an of type /// public class PublishOperationAttribute : OperationAttribute @@ -25,12 +25,12 @@ public class PublishOperationAttribute /// /// Initializes a new /// - /// The 's message type - public PublishOperationAttribute(Type messageType) : base(OperationType.Publish, messageType) { } + /// The 's message type + public PublishOperationAttribute(Type messageType) : base(V2OperationType.Publish, messageType) { } /// /// Initializes a new /// - public PublishOperationAttribute() : base(OperationType.Publish) { } + public PublishOperationAttribute() : base(V2OperationType.Publish) { } } diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/SubscribeOperationAttribute.cs b/src/Neuroglia.AsyncApi.Core/Attributes/SubscribeOperationAttribute.cs index 2b44543..eb63453 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/SubscribeOperationAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/Attributes/SubscribeOperationAttribute.cs @@ -16,7 +16,7 @@ namespace Neuroglia.AsyncApi; /// -/// Represents an used to mark a method as an of type +/// Represents an used to mark a method as an of type /// public class SubscribeOperationAttribute : OperationAttribute @@ -25,12 +25,12 @@ public class SubscribeOperationAttribute /// /// Initializes a new /// - /// The 's message type - public SubscribeOperationAttribute(Type messageType) : base(OperationType.Subscribe, messageType) { } + /// The 's message type + public SubscribeOperationAttribute(Type messageType) : base(V2OperationType.Subscribe, messageType) { } /// /// Initializes a new /// - public SubscribeOperationAttribute() : base(OperationType.Subscribe) { } + public SubscribeOperationAttribute() : base(V2OperationType.Subscribe) { } } diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/TagAttribute.cs b/src/Neuroglia.AsyncApi.Core/Attributes/TagAttribute.cs index cb0c3ae..0a797cb 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/TagAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/Attributes/TagAttribute.cs @@ -16,7 +16,7 @@ namespace Neuroglia.AsyncApi; /// -/// Represents an used to tag an method +/// Represents an used to tag an method /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] public class TagAttribute diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpBindingDefinition.cs index 77c5a8e..9fcc974 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpBindingDefinition.cs @@ -11,10 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Amqp; +namespace Neuroglia.AsyncApi.Bindings.Amqp; /// /// Represents the base record for all AMQP implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpChannelBindingDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpChannelBindingDefinition.cs index 36d3608..e01a4db 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpChannelBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Amqp; +namespace Neuroglia.AsyncApi.Bindings.Amqp; /// /// Represents the object used to configure an AMQP channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpChannelType.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpChannelType.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpChannelType.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpChannelType.cs index 5b4597f..02346c0 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpChannelType.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpChannelType.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Amqp; +namespace Neuroglia.AsyncApi.Bindings.Amqp; /// /// Enumerates all supported AMQP channel types diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpDeliveryMode.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpDeliveryMode.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpDeliveryMode.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpDeliveryMode.cs index 8091dad..fba9ee3 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpDeliveryMode.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpDeliveryMode.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Amqp; +namespace Neuroglia.AsyncApi.Bindings.Amqp; /// /// Enumerates all supported AMQP delivery modes diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpExchangeDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpExchangeDefinition.cs similarity index 98% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpExchangeDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpExchangeDefinition.cs index 6cfb420..fca5348 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpExchangeDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpExchangeDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Amqp; +namespace Neuroglia.AsyncApi.Bindings.Amqp; /// /// Represents the object used to configure an AMQP routing key based channel diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpExchangeType.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpExchangeType.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpExchangeType.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpExchangeType.cs index 96aad7c..d71dfb4 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpExchangeType.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpExchangeType.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Amqp; +namespace Neuroglia.AsyncApi.Bindings.Amqp; /// /// Enumerates all supported AMQP exchange types diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpMessageBindingDefinition.cs similarity index 94% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpMessageBindingDefinition.cs index 65bc8fe..93c2c08 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpMessageBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Amqp; +namespace Neuroglia.AsyncApi.Bindings.Amqp; /// /// Represents the object used to configure an AMQP 0.9+ message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpOperationBindingDefinition.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpOperationBindingDefinition.cs index 003ae98..93e275a 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpOperationBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Amqp; +namespace Neuroglia.AsyncApi.Bindings.Amqp; /// /// Represents the object used to configure an AMQP 0.9+ operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpQueueDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpQueueDefinition.cs similarity index 98% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpQueueDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpQueueDefinition.cs index 168d186..9bfd0ac 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpQueueDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpQueueDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Amqp; +namespace Neuroglia.AsyncApi.Bindings.Amqp; /// /// Represents the object used to configure an AMQP queue based channel diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpServerBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpServerBindingDefinition.cs index 4d6d5c6..e662484 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Amqp/AmqpServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Amqp/AmqpServerBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Amqp; +namespace Neuroglia.AsyncApi.Bindings.Amqp; /// /// Represents the object used to configure an AMQP 0.9+ server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1BindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1BindingDefinition.cs similarity index 60% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1BindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1BindingDefinition.cs index 8009803..685e97a 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1BindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1BindingDefinition.cs @@ -11,7 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.AmqpV1; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.AmqpV1; /// /// Represents the base record for all AMQP V1 implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1ChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1ChannelBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1ChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1ChannelBindingDefinition.cs index 3ea9091..644b240 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1ChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1ChannelBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.AmqpV1; +namespace Neuroglia.AsyncApi.Bindings.AmqpV1; /// /// Represents the object used to configure an AMQP 1.0 channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1MessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1MessageBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1MessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1MessageBindingDefinition.cs index 6e1f158..ababdd2 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1MessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1MessageBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.AmqpV1; +namespace Neuroglia.AsyncApi.Bindings.AmqpV1; /// /// Represents the object used to configure an AMQP 1.0 message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1OperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1OperationBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1OperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1OperationBindingDefinition.cs index b9f6f70..810d117 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1OperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1OperationBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.AmqpV1; +namespace Neuroglia.AsyncApi.Bindings.AmqpV1; /// /// Represents the object used to configure an AMQP 1.0 operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1ServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1ServerBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1ServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1ServerBindingDefinition.cs index 40aa37f..d0f01fb 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AmqpV1/AmqpV1ServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/AmqpV1/AmqpV1ServerBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.AmqpV1; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.AmqpV1; /// /// Represents the object used to configure an AMQP 1.0 server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQBindingDefinition.cs similarity index 60% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQBindingDefinition.cs index 26b665a..c01c8b7 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQBindingDefinition.cs @@ -11,7 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.AnypointMQ; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.AnypointMQ; /// /// Represents the base record for all Anypoint MQ implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQChannelBindingDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQChannelBindingDefinition.cs index fe5d4f0..99d245e 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQChannelBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.AnypointMQ; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.AnypointMQ; /// /// Represents the object used to configure an Anypoint MQ channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQMessageBindingDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQMessageBindingDefinition.cs index fd84069..0085620 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQMessageBindingDefinition.cs @@ -12,8 +12,9 @@ // limitations under the License. using Json.Schema; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.AnypointMQ; +namespace Neuroglia.AsyncApi.Bindings.AnypointMQ; /// /// Represents the object used to configure an Anypoint MQ message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQOperationBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQOperationBindingDefinition.cs index b86d58a..46b13c3 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQOperationBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.AnypointMQ; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.AnypointMQ; /// /// Represents the object used to configure an Anypoint MQ operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQServerBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQServerBindingDefinition.cs index 1058f2e..9a3e7a6 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/AnypointMQServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/AnypointMQServerBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.AnypointMQ; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.AnypointMQ; /// /// Represents the object used to configure an Anypoint MQ server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/JmsDestinationType.cs b/src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/JmsDestinationType.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/JmsDestinationType.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/JmsDestinationType.cs index 321e719..7905cab 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/AnypointMQ/JmsDestinationType.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/AnypointMQ/JmsDestinationType.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.AnypointMQ; +namespace Neuroglia.AsyncApi.Bindings.AnypointMQ; /// /// Enumerates all supported types of Anypoint MQ destinations diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/BindingDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/Bindings/BindingDefinitionCollection.cs similarity index 98% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/BindingDefinitionCollection.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/BindingDefinitionCollection.cs index 759028f..d733811 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/BindingDefinitionCollection.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/BindingDefinitionCollection.cs @@ -13,7 +13,7 @@ using System.Reflection; -namespace Neuroglia.AsyncApi.v2.Bindings; +namespace Neuroglia.AsyncApi.Bindings; /// /// Represents the base record for all implementations diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/ChannelBindingDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/Bindings/ChannelBindingDefinitionCollection.cs similarity index 77% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/ChannelBindingDefinitionCollection.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/ChannelBindingDefinitionCollection.cs index b21c586..482c35f 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/ChannelBindingDefinitionCollection.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/ChannelBindingDefinitionCollection.cs @@ -11,30 +11,31 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings.Amqp; -using Neuroglia.AsyncApi.v2.Bindings.AmqpV1; -using Neuroglia.AsyncApi.v2.Bindings.AnypointMQ; -using Neuroglia.AsyncApi.v2.Bindings.GooglePubSub; -using Neuroglia.AsyncApi.v2.Bindings.Http; -using Neuroglia.AsyncApi.v2.Bindings.IbmMQ; -using Neuroglia.AsyncApi.v2.Bindings.Jms; -using Neuroglia.AsyncApi.v2.Bindings.Kafka; -using Neuroglia.AsyncApi.v2.Bindings.Mercure; -using Neuroglia.AsyncApi.v2.Bindings.Mqtt; -using Neuroglia.AsyncApi.v2.Bindings.MqttV5; -using Neuroglia.AsyncApi.v2.Bindings.Nats; -using Neuroglia.AsyncApi.v2.Bindings.Pulsar; -using Neuroglia.AsyncApi.v2.Bindings.Redis; -using Neuroglia.AsyncApi.v2.Bindings.Sns; -using Neuroglia.AsyncApi.v2.Bindings.Solace; -using Neuroglia.AsyncApi.v2.Bindings.Sqs; -using Neuroglia.AsyncApi.v2.Bindings.Stomp; -using Neuroglia.AsyncApi.v2.Bindings.WebSockets; - -namespace Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings.Amqp; +using Neuroglia.AsyncApi.Bindings.AmqpV1; +using Neuroglia.AsyncApi.Bindings.AnypointMQ; +using Neuroglia.AsyncApi.Bindings.GooglePubSub; +using Neuroglia.AsyncApi.Bindings.Http; +using Neuroglia.AsyncApi.Bindings.IbmMQ; +using Neuroglia.AsyncApi.Bindings.Jms; +using Neuroglia.AsyncApi.Bindings.Kafka; +using Neuroglia.AsyncApi.Bindings.Mercure; +using Neuroglia.AsyncApi.Bindings.Mqtt; +using Neuroglia.AsyncApi.Bindings.MqttV5; +using Neuroglia.AsyncApi.Bindings.Nats; +using Neuroglia.AsyncApi.Bindings.Pulsar; +using Neuroglia.AsyncApi.Bindings.Redis; +using Neuroglia.AsyncApi.Bindings.Sns; +using Neuroglia.AsyncApi.Bindings.Solace; +using Neuroglia.AsyncApi.Bindings.Sqs; +using Neuroglia.AsyncApi.Bindings.Stomp; +using Neuroglia.AsyncApi.Bindings.WebSockets; +using Neuroglia.AsyncApi.v2; + +namespace Neuroglia.AsyncApi.Bindings; /// -/// Represents the object used to configure a 's s +/// Represents the object used to configure a 's s /// [DataContract] public record ChannelBindingDefinitionCollection @@ -158,25 +159,25 @@ public record ChannelBindingDefinitionCollection /// public override IEnumerable AsEnumerable() { - if (this.Http != null) yield return this.Http; - if (this.Ws != null) yield return this.Ws; - if (this.Kafka != null) yield return this.Kafka; - if (this.AnypointMQ != null) yield return this.AnypointMQ; - if (this.Amqp != null) yield return this.Amqp; - if (this.Amqp1 != null) yield return this.Amqp1; - if (this.Mqtt != null) yield return this.Mqtt; - if (this.Mqtt5 != null) yield return this.Mqtt5; - if (this.Nats != null) yield return this.Nats; - if (this.Jms != null) yield return this.Jms; - if (this.Sns != null) yield return this.Sns; - if (this.Solace != null) yield return this.Solace; - if (this.Sqs != null) yield return this.Sqs; - if (this.Stomp != null) yield return this.Stomp; - if (this.Redis != null) yield return this.Redis; - if (this.Mercure != null) yield return this.Mercure; - if (this.IbmMQ != null) yield return this.IbmMQ; - if (this.GooglePubSub != null) yield return this.GooglePubSub; - if (this.Pulsar != null) yield return this.Pulsar; + if (Http != null) yield return Http; + if (Ws != null) yield return Ws; + if (Kafka != null) yield return Kafka; + if (AnypointMQ != null) yield return AnypointMQ; + if (Amqp != null) yield return Amqp; + if (Amqp1 != null) yield return Amqp1; + if (Mqtt != null) yield return Mqtt; + if (Mqtt5 != null) yield return Mqtt5; + if (Nats != null) yield return Nats; + if (Jms != null) yield return Jms; + if (Sns != null) yield return Sns; + if (Solace != null) yield return Solace; + if (Sqs != null) yield return Sqs; + if (Stomp != null) yield return Stomp; + if (Redis != null) yield return Redis; + if (Mercure != null) yield return Mercure; + if (IbmMQ != null) yield return IbmMQ; + if (GooglePubSub != null) yield return GooglePubSub; + if (Pulsar != null) yield return Pulsar; } } diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubBindingDefinition.cs similarity index 60% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubBindingDefinition.cs index 0ac3cee..798aa21 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubBindingDefinition.cs @@ -11,7 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.GooglePubSub; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.GooglePubSub; /// /// Represents the base record for all Google Pub/Sub implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubChannelBindingDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubChannelBindingDefinition.cs index 7c0c5ab..2d5d0fe 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubChannelBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.GooglePubSub; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.GooglePubSub; /// /// Represents the object used to configure a Google Pub/Sub channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubMessageBindingDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubMessageBindingDefinition.cs index 8aa6273..a708503 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubMessageBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.GooglePubSub; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.GooglePubSub; /// /// Represents the object used to configure a Google Pub/Sub message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubMessageEncoding.cs b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubMessageEncoding.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubMessageEncoding.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubMessageEncoding.cs index 8cae76d..de9a76b 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubMessageEncoding.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubMessageEncoding.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.GooglePubSub; +namespace Neuroglia.AsyncApi.Bindings.GooglePubSub; /// /// Enumerates all supported Google Pub/Sub message encodings diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubMessageStoragePolicyDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubMessageStoragePolicyDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubMessageStoragePolicyDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubMessageStoragePolicyDefinition.cs index 0aabdd9..dba4b61 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubMessageStoragePolicyDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubMessageStoragePolicyDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.GooglePubSub; +namespace Neuroglia.AsyncApi.Bindings.GooglePubSub; /// /// Represents an object used to configure the policy constraining the set of Google Cloud Platform regions where messages published to the topic may be stored diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubOperationBindingDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubOperationBindingDefinition.cs index 057ce18..ebb8919 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubOperationBindingDefinition.cs @@ -12,8 +12,9 @@ // limitations under the License. using Json.Schema; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.GooglePubSub; +namespace Neuroglia.AsyncApi.Bindings.GooglePubSub; /// /// Represents the object used to configure a Google Pub/Sub operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubSchemaDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubSchemaDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubSchemaDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubSchemaDefinition.cs index 5fb2826..239cffb 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubSchemaDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubSchemaDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.GooglePubSub; +namespace Neuroglia.AsyncApi.Bindings.GooglePubSub; /// /// Represents the object used to configure a Google Pub/Sub schema diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubSchemaSettings.cs b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubSchemaSettings.cs similarity index 76% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubSchemaSettings.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubSchemaSettings.cs index 2b1d80f..c3b1f57 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubSchemaSettings.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubSchemaSettings.cs @@ -11,7 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.GooglePubSub; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.Bindings.GooglePubSub; /// /// Represents the settings for validating messages published against a schema diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubServerBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubServerBindingDefinition.cs index 98568c7..bbbd1da 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/GooglePubSub/GooglePubSubServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/GooglePubSub/GooglePubSubServerBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.GooglePubSub; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.GooglePubSub; /// /// Represents the object used to configure a Google PubSub server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpBindingDefinition.cs index 3006b4d..fd34b48 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpBindingDefinition.cs @@ -11,10 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Http; +namespace Neuroglia.AsyncApi.Bindings.Http; /// /// Represents the base record for all HTTP implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpBindingOperationType.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpBindingOperationType.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpBindingOperationType.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpBindingOperationType.cs index cd6a679..8599538 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpBindingOperationType.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpBindingOperationType.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Http; +namespace Neuroglia.AsyncApi.Bindings.Http; /// /// Enumerates all types of http binding operation types diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpChannelBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpChannelBindingDefinition.cs index 1c3f945..8f24856 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpChannelBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Http; +namespace Neuroglia.AsyncApi.Bindings.Http; /// /// Represents the object used to configure an http channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpMessageBindingDefinition.cs similarity index 94% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpMessageBindingDefinition.cs index 4117f6a..9ae077c 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpMessageBindingDefinition.cs @@ -12,9 +12,9 @@ // limitations under the License. using Json.Schema; -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Http; +namespace Neuroglia.AsyncApi.Bindings.Http; /// /// Represents the object used to configure an http message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpMethod.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpMethod.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpMethod.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpMethod.cs index dd4537a..26f269b 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpMethod.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpMethod.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Http; +namespace Neuroglia.AsyncApi.Bindings.Http; /// /// Enumerates all supported HTTP methods diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpOperationBindingDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpOperationBindingDefinition.cs index 1df22b1..575ecc4 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpOperationBindingDefinition.cs @@ -12,8 +12,9 @@ // limitations under the License. using Json.Schema; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Http; +namespace Neuroglia.AsyncApi.Bindings.Http; /// /// Represents the object used to configure an http operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpServerBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpServerBindingDefinition.cs index 9caf89b..f2f7987 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Http/HttpServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Http/HttpServerBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Http; +namespace Neuroglia.AsyncApi.Bindings.Http; /// /// Represents the object used to configure an http server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IBindingDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IBindingDefinition.cs index d551c4d..e353bad 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IBindingDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings; +namespace Neuroglia.AsyncApi.Bindings; /// /// Defines the fundamentals of an Async API binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IBindingDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IBindingDefinitionCollection.cs similarity index 93% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IBindingDefinitionCollection.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IBindingDefinitionCollection.cs index 18c32a6..63c1d4a 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IBindingDefinitionCollection.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IBindingDefinitionCollection.cs @@ -11,9 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi.v2.Bindings; +namespace Neuroglia.AsyncApi.Bindings; /// /// Defines the fundamentals of a collection of s diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IChannelBindingDefinition.cs similarity index 54% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IChannelBindingDefinition.cs index 9888364..55e2b0a 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IChannelBindingDefinition.cs @@ -11,7 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.Bindings; /// /// Defines the fundamentals of a channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IMessageBindingDefinition.cs similarity index 54% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IMessageBindingDefinition.cs index d847d08..32defb5 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IMessageBindingDefinition.cs @@ -11,7 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.Bindings; /// /// Defines the fundamentals of a message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IOperationBindingDefinition.cs similarity index 54% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IOperationBindingDefinition.cs index df264a0..d6f5e92 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IOperationBindingDefinition.cs @@ -11,7 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.Bindings; /// /// Defines the fundamentals of an operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IServerBindingDefinition.cs similarity index 53% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IServerBindingDefinition.cs index 2e90880..32954c0 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IServerBindingDefinition.cs @@ -11,7 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.Bindings; /// /// Defines the fundamentals of a server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQBindingDefinition.cs similarity index 60% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQBindingDefinition.cs index 238afac..4cb90d2 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQBindingDefinition.cs @@ -11,7 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.IbmMQ; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.IbmMQ; /// /// Represents the base record for all IBMMQ implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQChannelBindingDefinition.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQChannelBindingDefinition.cs index 1c788c9..729d85d 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQChannelBindingDefinition.cs @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.Bindings; using Neuroglia.AsyncApi.v2.Bindings.Solace; -namespace Neuroglia.AsyncApi.v2.Bindings.IbmMQ; +namespace Neuroglia.AsyncApi.Bindings.IbmMQ; /// /// Represents the object used to configure an IBMMQ channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQDestinationType.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQDestinationType.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQDestinationType.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQDestinationType.cs index afd5fd0..8622f16 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQDestinationType.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQDestinationType.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.IbmMQ; +namespace Neuroglia.AsyncApi.Bindings.IbmMQ; /// /// Enumerates all IBMMQ destination types diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQMessageBindingDefinition.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQMessageBindingDefinition.cs index 3b091e5..bc87e84 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQMessageBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.IbmMQ; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.IbmMQ; /// /// Represents the object used to configure an IBMMQ message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQMessageType.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQMessageType.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQMessageType.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQMessageType.cs index 448e536..2671d90 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQMessageType.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQMessageType.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.IbmMQ; +namespace Neuroglia.AsyncApi.Bindings.IbmMQ; /// /// Enumerates all IBM MQ message types diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQOperationBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQOperationBindingDefinition.cs index 02c58bb..5089204 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQOperationBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.IbmMQ; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.IbmMQ; /// /// Represents the object used to configure an IBMMQ operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQQueueDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQQueueDefinition.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQQueueDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQQueueDefinition.cs index 817a730..73ee6a5 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQQueueDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQQueueDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.IbmMQ; +namespace Neuroglia.AsyncApi.Bindings.IbmMQ; /// /// Represents the object used to configure an IBMMQ queue diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQServerBindingDefinition.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQServerBindingDefinition.cs index 9b30896..2eba075 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQServerBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.IbmMQ; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.IbmMQ; /// /// Represents the object used to configure an IBMMQ server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQTopicDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQTopicDefinition.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQTopicDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQTopicDefinition.cs index 1bb2860..a208f3f 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/IbmMQ/IbmMQTopicDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQTopicDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.IbmMQ; +namespace Neuroglia.AsyncApi.Bindings.IbmMQ; /// /// Represents the object used to configure an IBMMQ topic diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsBindingDefinition.cs similarity index 60% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsBindingDefinition.cs index 7bc947b..de7c023 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsBindingDefinition.cs @@ -11,7 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Jms; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Jms; /// /// Represents the base record for all JMS implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsChannelBindingDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsChannelBindingDefinition.cs index c685796..0c333fe 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsChannelBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Jms; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Jms; /// /// Represents the object used to configure a JMS channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsDestinationType.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsDestinationType.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsDestinationType.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsDestinationType.cs index 67b685d..e2c7c7c 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsDestinationType.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsDestinationType.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Jms; +namespace Neuroglia.AsyncApi.Bindings.Jms; /// /// Enumerates all supported types of JMS destinations diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsMessageBindingDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsMessageBindingDefinition.cs index 55bd72b..56f779f 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsMessageBindingDefinition.cs @@ -12,8 +12,9 @@ // limitations under the License. using Json.Schema; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Jms; +namespace Neuroglia.AsyncApi.Bindings.Jms; /// /// Represents the object used to configure a JMS message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsOperationBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsOperationBindingDefinition.cs index 7cbb412..d4448ef 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsOperationBindingDefinition.cs @@ -12,8 +12,9 @@ // limitations under the License. using Json.Schema; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Jms; +namespace Neuroglia.AsyncApi.Bindings.Jms; /// /// Represents the object used to configure a JMS operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsServerBindingDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsServerBindingDefinition.cs index 2483814..6be11e9 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Jms/JmsServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Jms/JmsServerBindingDefinition.cs @@ -12,8 +12,9 @@ // limitations under the License. using Json.Schema; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Jms; +namespace Neuroglia.AsyncApi.Bindings.Jms; /// /// Represents the object used to configure a JMS server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaBindingDefinition.cs similarity index 60% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaBindingDefinition.cs index 9bd2e81..fad7341 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaBindingDefinition.cs @@ -11,7 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Kafka; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Kafka; /// /// Represents the base record for all Kafka implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaChannelBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaChannelBindingDefinition.cs index a7f5e83..df863b0 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaChannelBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Kafka; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Kafka; /// /// Represents the object used to configure a Kafka channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaMessageBindingDefinition.cs similarity index 94% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaMessageBindingDefinition.cs index 313ea6e..141f7b8 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaMessageBindingDefinition.cs @@ -12,8 +12,9 @@ // limitations under the License. using Json.Schema; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Kafka; +namespace Neuroglia.AsyncApi.Bindings.Kafka; /// /// Represents the object used to configure a Kafka message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaOperationBindingDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaOperationBindingDefinition.cs index dcc7d22..856a092 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaOperationBindingDefinition.cs @@ -12,8 +12,9 @@ // limitations under the License. using Json.Schema; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Kafka; +namespace Neuroglia.AsyncApi.Bindings.Kafka; /// /// Represents the object used to configure a Kafka operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaServerBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaServerBindingDefinition.cs index 2fea50f..b7664d0 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Kafka/KafkaServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Kafka/KafkaServerBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Kafka; +namespace Neuroglia.AsyncApi.Bindings.Kafka; /// /// Represents the object used to configure a Kafka server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureBindingDefinition.cs similarity index 60% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureBindingDefinition.cs index d194981..130c312 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureBindingDefinition.cs @@ -11,7 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Mercure; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Mercure; /// /// Represents the base record for all Mercure implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureChannelBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureChannelBindingDefinition.cs index 5e8d6fa..e13b052 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureChannelBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Mercure; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Mercure; /// /// Represents the object used to configure a Mercure channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureMessageBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureMessageBindingDefinition.cs index 4e85fd6..cc220e4 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureMessageBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Mercure; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Mercure; /// /// Represents the object used to configure a Mercure message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureOperationBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureOperationBindingDefinition.cs index 0e009b3..70de493 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureOperationBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Mercure; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Mercure; /// /// Represents the object used to configure a Mercure operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureServerBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureServerBindingDefinition.cs index 673eb1a..8c43fe4 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mercure/MercureServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Mercure/MercureServerBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Mercure; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Mercure; /// /// Represents the object used to configure a Mercure server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/MessageBindingDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/Bindings/MessageBindingDefinitionCollection.cs similarity index 77% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/MessageBindingDefinitionCollection.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/MessageBindingDefinitionCollection.cs index 45896bc..40f02ab 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/MessageBindingDefinitionCollection.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/MessageBindingDefinitionCollection.cs @@ -11,30 +11,31 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings.Amqp; -using Neuroglia.AsyncApi.v2.Bindings.AmqpV1; -using Neuroglia.AsyncApi.v2.Bindings.AnypointMQ; -using Neuroglia.AsyncApi.v2.Bindings.GooglePubSub; -using Neuroglia.AsyncApi.v2.Bindings.Http; -using Neuroglia.AsyncApi.v2.Bindings.IbmMQ; -using Neuroglia.AsyncApi.v2.Bindings.Jms; -using Neuroglia.AsyncApi.v2.Bindings.Kafka; -using Neuroglia.AsyncApi.v2.Bindings.Mercure; -using Neuroglia.AsyncApi.v2.Bindings.Mqtt; -using Neuroglia.AsyncApi.v2.Bindings.MqttV5; -using Neuroglia.AsyncApi.v2.Bindings.Nats; -using Neuroglia.AsyncApi.v2.Bindings.Pulsar; -using Neuroglia.AsyncApi.v2.Bindings.Redis; -using Neuroglia.AsyncApi.v2.Bindings.Sns; -using Neuroglia.AsyncApi.v2.Bindings.Solace; -using Neuroglia.AsyncApi.v2.Bindings.Sqs; -using Neuroglia.AsyncApi.v2.Bindings.Stomp; -using Neuroglia.AsyncApi.v2.Bindings.WebSockets; - -namespace Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings.Amqp; +using Neuroglia.AsyncApi.Bindings.AmqpV1; +using Neuroglia.AsyncApi.Bindings.AnypointMQ; +using Neuroglia.AsyncApi.Bindings.GooglePubSub; +using Neuroglia.AsyncApi.Bindings.Http; +using Neuroglia.AsyncApi.Bindings.IbmMQ; +using Neuroglia.AsyncApi.Bindings.Jms; +using Neuroglia.AsyncApi.Bindings.Kafka; +using Neuroglia.AsyncApi.Bindings.Mercure; +using Neuroglia.AsyncApi.Bindings.Mqtt; +using Neuroglia.AsyncApi.Bindings.MqttV5; +using Neuroglia.AsyncApi.Bindings.Nats; +using Neuroglia.AsyncApi.Bindings.Pulsar; +using Neuroglia.AsyncApi.Bindings.Redis; +using Neuroglia.AsyncApi.Bindings.Sns; +using Neuroglia.AsyncApi.Bindings.Solace; +using Neuroglia.AsyncApi.Bindings.Sqs; +using Neuroglia.AsyncApi.Bindings.Stomp; +using Neuroglia.AsyncApi.Bindings.WebSockets; +using Neuroglia.AsyncApi.v2; + +namespace Neuroglia.AsyncApi.Bindings; /// -/// Represents the object used to configure a 's s +/// Represents the object used to configure a 's s /// [DataContract] public record MessageBindingDefinitionCollection @@ -158,25 +159,25 @@ public record MessageBindingDefinitionCollection /// public override IEnumerable AsEnumerable() { - if (this.Http != null) yield return this.Http; - if (this.Ws != null) yield return this.Ws; - if (this.Kafka != null) yield return this.Kafka; - if (this.AnypointMQ != null) yield return this.AnypointMQ; - if (this.Amqp != null) yield return this.Amqp; - if (this.Amqp1 != null) yield return this.Amqp1; - if (this.Mqtt != null) yield return this.Mqtt; - if (this.Mqtt5 != null) yield return this.Mqtt5; - if (this.Nats != null) yield return this.Nats; - if (this.Jms != null) yield return this.Jms; - if (this.Sns != null) yield return this.Sns; - if (this.Solace != null) yield return this.Solace; - if (this.Sqs != null) yield return this.Sqs; - if (this.Stomp != null) yield return this.Stomp; - if (this.Redis != null) yield return this.Redis; - if (this.Mercure != null) yield return this.Mercure; - if (this.IbmMQ != null) yield return this.IbmMQ; - if (this.GooglePubSub != null) yield return this.GooglePubSub; - if (this.Pulsar != null) yield return this.Pulsar; + if (Http != null) yield return Http; + if (Ws != null) yield return Ws; + if (Kafka != null) yield return Kafka; + if (AnypointMQ != null) yield return AnypointMQ; + if (Amqp != null) yield return Amqp; + if (Amqp1 != null) yield return Amqp1; + if (Mqtt != null) yield return Mqtt; + if (Mqtt5 != null) yield return Mqtt5; + if (Nats != null) yield return Nats; + if (Jms != null) yield return Jms; + if (Sns != null) yield return Sns; + if (Solace != null) yield return Solace; + if (Sqs != null) yield return Sqs; + if (Stomp != null) yield return Stomp; + if (Redis != null) yield return Redis; + if (Mercure != null) yield return Mercure; + if (IbmMQ != null) yield return IbmMQ; + if (GooglePubSub != null) yield return GooglePubSub; + if (Pulsar != null) yield return Pulsar; } } diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttBindingDefinition.cs index 67e1b74..139592d 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttBindingDefinition.cs @@ -11,10 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Mqtt; +namespace Neuroglia.AsyncApi.Bindings.Mqtt; /// /// Represents the base record for all Mqtt implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttChannelBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttChannelBindingDefinition.cs index cd63f2e..b5a7f7b 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttChannelBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Mqtt; +namespace Neuroglia.AsyncApi.Bindings.Mqtt; /// /// Represents the object used to configure an MQTT channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttLastWillDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttLastWillDefinition.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttLastWillDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttLastWillDefinition.cs index 466593c..ef53d74 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttLastWillDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttLastWillDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Mqtt; +namespace Neuroglia.AsyncApi.Bindings.Mqtt; /// /// Represents an object used to configure an 's last Will and Testament diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttMessageBindingDefinition.cs similarity index 93% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttMessageBindingDefinition.cs index d615749..5d0a8f8 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttMessageBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Mqtt; +namespace Neuroglia.AsyncApi.Bindings.Mqtt; /// /// Represents the object used to configure an MQTT message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttOperationBindingDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttOperationBindingDefinition.cs index df6c60a..9a8d51b 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttOperationBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Mqtt; +namespace Neuroglia.AsyncApi.Bindings.Mqtt; /// /// Represents the object used to configure an MQTT operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttQoSLevel.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttQoSLevel.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttQoSLevel.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttQoSLevel.cs index d2788aa..b4465cc 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttQoSLevel.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttQoSLevel.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Mqtt; +namespace Neuroglia.AsyncApi.Bindings.Mqtt; /// /// Enumerates all supported MQTT Quality of Service types diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttServerBindingDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttServerBindingDefinition.cs index 2123c78..3438791 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Mqtt/MqttServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Mqtt/MqttServerBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Mqtt; +namespace Neuroglia.AsyncApi.Bindings.Mqtt; /// /// Represents the object used to configure an MQTT server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5BindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5BindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5BindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5BindingDefinition.cs index 9898e00..9d574e2 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5BindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5BindingDefinition.cs @@ -11,10 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.MqttV5; +namespace Neuroglia.AsyncApi.Bindings.MqttV5; /// /// Represents the base record for all Mqtt V5 implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5ChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5ChannelBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5ChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5ChannelBindingDefinition.cs index 54ed702..d2b2569 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5ChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5ChannelBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.MqttV5; +namespace Neuroglia.AsyncApi.Bindings.MqttV5; /// /// Represents the object used to configure an MQTT V5+ channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5MessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5MessageBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5MessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5MessageBindingDefinition.cs index 872ca97..60afdab 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5MessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5MessageBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.MqttV5; +namespace Neuroglia.AsyncApi.Bindings.MqttV5; /// /// Represents the object used to configure an MQTT V5+ message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5OperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5OperationBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5OperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5OperationBindingDefinition.cs index 2794095..478c8a7 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5OperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5OperationBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.MqttV5; +namespace Neuroglia.AsyncApi.Bindings.MqttV5; /// /// Represents the object used to configure an MQTT V5+ operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5ServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5ServerBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5ServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5ServerBindingDefinition.cs index cada49b..8214815 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/MqttV5/MqttV5ServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/MqttV5/MqttV5ServerBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.MqttV5; +namespace Neuroglia.AsyncApi.Bindings.MqttV5; /// /// Represents the object used to configure an MQTT V5+ server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsBindingDefinition.cs index bbf3d44..460be95 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsBindingDefinition.cs @@ -11,10 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Nats; +namespace Neuroglia.AsyncApi.Bindings.Nats; /// /// Represents the base record for all NATS implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsChannelBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsChannelBindingDefinition.cs index c1ead73..dbde1ae 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsChannelBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Nats; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Nats; /// /// Represents the object used to configure a NATS channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsMessageBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsMessageBindingDefinition.cs index 77333d0..d6e249f 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsMessageBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Nats; +namespace Neuroglia.AsyncApi.Bindings.Nats; /// /// Represents the object used to configure a NATS message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsOperationBindingDefinition.cs similarity index 93% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsOperationBindingDefinition.cs index 38f04b5..11aaf95 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsOperationBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Nats; +namespace Neuroglia.AsyncApi.Bindings.Nats; /// /// Represents the object used to configure a NATS operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsServerBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsServerBindingDefinition.cs index 28be605..a7c438c 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Nats/NatsServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Nats/NatsServerBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Nats; +namespace Neuroglia.AsyncApi.Bindings.Nats; /// /// Represents the object used to configure a NATS server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/OperationBindingDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/Bindings/OperationBindingDefinitionCollection.cs similarity index 77% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/OperationBindingDefinitionCollection.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/OperationBindingDefinitionCollection.cs index 87c28b4..55f8c9b 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/OperationBindingDefinitionCollection.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/OperationBindingDefinitionCollection.cs @@ -11,30 +11,31 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings.Amqp; -using Neuroglia.AsyncApi.v2.Bindings.AmqpV1; -using Neuroglia.AsyncApi.v2.Bindings.AnypointMQ; -using Neuroglia.AsyncApi.v2.Bindings.GooglePubSub; -using Neuroglia.AsyncApi.v2.Bindings.Http; -using Neuroglia.AsyncApi.v2.Bindings.IbmMQ; -using Neuroglia.AsyncApi.v2.Bindings.Jms; -using Neuroglia.AsyncApi.v2.Bindings.Kafka; -using Neuroglia.AsyncApi.v2.Bindings.Mercure; -using Neuroglia.AsyncApi.v2.Bindings.Mqtt; -using Neuroglia.AsyncApi.v2.Bindings.MqttV5; -using Neuroglia.AsyncApi.v2.Bindings.Nats; -using Neuroglia.AsyncApi.v2.Bindings.Pulsar; -using Neuroglia.AsyncApi.v2.Bindings.Redis; -using Neuroglia.AsyncApi.v2.Bindings.Sns; -using Neuroglia.AsyncApi.v2.Bindings.Solace; -using Neuroglia.AsyncApi.v2.Bindings.Sqs; -using Neuroglia.AsyncApi.v2.Bindings.Stomp; -using Neuroglia.AsyncApi.v2.Bindings.WebSockets; - -namespace Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings.Amqp; +using Neuroglia.AsyncApi.Bindings.AmqpV1; +using Neuroglia.AsyncApi.Bindings.AnypointMQ; +using Neuroglia.AsyncApi.Bindings.GooglePubSub; +using Neuroglia.AsyncApi.Bindings.Http; +using Neuroglia.AsyncApi.Bindings.IbmMQ; +using Neuroglia.AsyncApi.Bindings.Jms; +using Neuroglia.AsyncApi.Bindings.Kafka; +using Neuroglia.AsyncApi.Bindings.Mercure; +using Neuroglia.AsyncApi.Bindings.Mqtt; +using Neuroglia.AsyncApi.Bindings.MqttV5; +using Neuroglia.AsyncApi.Bindings.Nats; +using Neuroglia.AsyncApi.Bindings.Pulsar; +using Neuroglia.AsyncApi.Bindings.Redis; +using Neuroglia.AsyncApi.Bindings.Sns; +using Neuroglia.AsyncApi.Bindings.Solace; +using Neuroglia.AsyncApi.Bindings.Sqs; +using Neuroglia.AsyncApi.Bindings.Stomp; +using Neuroglia.AsyncApi.Bindings.WebSockets; +using Neuroglia.AsyncApi.v2; + +namespace Neuroglia.AsyncApi.Bindings; /// -/// Represents the object used to configure a 's s +/// Represents the object used to configure a 's s /// [DataContract] public record OperationBindingDefinitionCollection @@ -158,25 +159,25 @@ public record OperationBindingDefinitionCollection /// public override IEnumerable AsEnumerable() { - if (this.Http != null) yield return this.Http; - if (this.Ws != null) yield return this.Ws; - if (this.Kafka != null) yield return this.Kafka; - if (this.AnypointMQ != null) yield return this.AnypointMQ; - if (this.Amqp != null) yield return this.Amqp; - if (this.Amqp1 != null) yield return this.Amqp1; - if (this.Mqtt != null) yield return this.Mqtt; - if (this.Mqtt5 != null) yield return this.Mqtt5; - if (this.Nats != null) yield return this.Nats; - if (this.Jms != null) yield return this.Jms; - if (this.Sns != null) yield return this.Sns; - if (this.Solace != null) yield return this.Solace; - if (this.Sqs != null) yield return this.Sqs; - if (this.Stomp != null) yield return this.Stomp; - if (this.Redis != null) yield return this.Redis; - if (this.Mercure != null) yield return this.Mercure; - if (this.IbmMQ != null) yield return this.IbmMQ; - if (this.GooglePubSub != null) yield return this.GooglePubSub; - if (this.Pulsar != null) yield return this.Pulsar; + if (Http != null) yield return Http; + if (Ws != null) yield return Ws; + if (Kafka != null) yield return Kafka; + if (AnypointMQ != null) yield return AnypointMQ; + if (Amqp != null) yield return Amqp; + if (Amqp1 != null) yield return Amqp1; + if (Mqtt != null) yield return Mqtt; + if (Mqtt5 != null) yield return Mqtt5; + if (Nats != null) yield return Nats; + if (Jms != null) yield return Jms; + if (Sns != null) yield return Sns; + if (Solace != null) yield return Solace; + if (Sqs != null) yield return Sqs; + if (Stomp != null) yield return Stomp; + if (Redis != null) yield return Redis; + if (Mercure != null) yield return Mercure; + if (IbmMQ != null) yield return IbmMQ; + if (GooglePubSub != null) yield return GooglePubSub; + if (Pulsar != null) yield return Pulsar; } } diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarBindingDefinition.cs similarity index 60% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarBindingDefinition.cs index 9b1bce5..0f16dc2 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarBindingDefinition.cs @@ -11,7 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Pulsar; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Pulsar; /// /// Represents the base record for all Pulsar implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarChannelBindingDefinition.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarChannelBindingDefinition.cs index 7aabf94..b571f77 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarChannelBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Pulsar; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Pulsar; /// /// Represents the object used to configure a Pulsar channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarMessageBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarMessageBindingDefinition.cs index 99de6ef..16fdaeb 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarMessageBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Pulsar; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Pulsar; /// /// Represents the object used to configure a Pulsar message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarOperationBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarOperationBindingDefinition.cs index 6877ec6..fc5372d 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarOperationBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Pulsar; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Pulsar; /// /// Represents the object used to configure a Pulsar operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarRetentionPolicyDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarRetentionPolicyDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarRetentionPolicyDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarRetentionPolicyDefinition.cs index cea8196..2ce6643 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarRetentionPolicyDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarRetentionPolicyDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Pulsar; +namespace Neuroglia.AsyncApi.Bindings.Pulsar; /// /// Represents the object used to configure a Pulsar channel's retention policy diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarServerBindingDefinition.cs similarity index 94% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarServerBindingDefinition.cs index 9a1845b..2d7a895 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarServerBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Pulsar; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Pulsar; /// /// Represents the object used to configure a Pulsar server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarTopicTypes.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarTopicTypes.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarTopicTypes.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarTopicTypes.cs index c0297ae..c545504 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Pulsar/PulsarTopicTypes.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Pulsar/PulsarTopicTypes.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Pulsar; +namespace Neuroglia.AsyncApi.Bindings.Pulsar; /// /// Enumerates all Pulsar topic types diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisBindingDefinition.cs index a679990..8f2d69b 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisBindingDefinition.cs @@ -11,10 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Redis; +namespace Neuroglia.AsyncApi.Bindings.Redis; /// /// Represents the base record for all REDIS implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisChannelBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisChannelBindingDefinition.cs index acbbb35..7270261 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisChannelBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Redis; +namespace Neuroglia.AsyncApi.Bindings.Redis; /// /// Represents the object used to configure a Redis channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisMessageBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisMessageBindingDefinition.cs index 4a9ff20..6297808 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisMessageBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Redis; +namespace Neuroglia.AsyncApi.Bindings.Redis; /// /// Represents the object used to configure a Redis message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisOperationBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisOperationBindingDefinition.cs index 6d0ddcc..4835bb8 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisOperationBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Redis; +namespace Neuroglia.AsyncApi.Bindings.Redis; /// /// Represents the object used to configure a Redis operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisServerBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisServerBindingDefinition.cs index 85efda4..5f56bc9 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Redis/RedisServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Redis/RedisServerBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.Redis; +namespace Neuroglia.AsyncApi.Bindings.Redis; /// /// Represents the object used to configure a Redis server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/ServerBindingDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/Bindings/ServerBindingDefinitionCollection.cs similarity index 77% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/ServerBindingDefinitionCollection.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/ServerBindingDefinitionCollection.cs index 26ad948..4f3b28e 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/ServerBindingDefinitionCollection.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/ServerBindingDefinitionCollection.cs @@ -11,30 +11,31 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings.Amqp; -using Neuroglia.AsyncApi.v2.Bindings.AmqpV1; -using Neuroglia.AsyncApi.v2.Bindings.AnypointMQ; -using Neuroglia.AsyncApi.v2.Bindings.GooglePubSub; -using Neuroglia.AsyncApi.v2.Bindings.Http; -using Neuroglia.AsyncApi.v2.Bindings.IbmMQ; -using Neuroglia.AsyncApi.v2.Bindings.Jms; -using Neuroglia.AsyncApi.v2.Bindings.Kafka; -using Neuroglia.AsyncApi.v2.Bindings.Mercure; -using Neuroglia.AsyncApi.v2.Bindings.Mqtt; -using Neuroglia.AsyncApi.v2.Bindings.MqttV5; -using Neuroglia.AsyncApi.v2.Bindings.Nats; -using Neuroglia.AsyncApi.v2.Bindings.Pulsar; -using Neuroglia.AsyncApi.v2.Bindings.Redis; -using Neuroglia.AsyncApi.v2.Bindings.Sns; -using Neuroglia.AsyncApi.v2.Bindings.Solace; -using Neuroglia.AsyncApi.v2.Bindings.Sqs; -using Neuroglia.AsyncApi.v2.Bindings.Stomp; -using Neuroglia.AsyncApi.v2.Bindings.WebSockets; - -namespace Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings.Amqp; +using Neuroglia.AsyncApi.Bindings.AmqpV1; +using Neuroglia.AsyncApi.Bindings.AnypointMQ; +using Neuroglia.AsyncApi.Bindings.GooglePubSub; +using Neuroglia.AsyncApi.Bindings.Http; +using Neuroglia.AsyncApi.Bindings.IbmMQ; +using Neuroglia.AsyncApi.Bindings.Jms; +using Neuroglia.AsyncApi.Bindings.Kafka; +using Neuroglia.AsyncApi.Bindings.Mercure; +using Neuroglia.AsyncApi.Bindings.Mqtt; +using Neuroglia.AsyncApi.Bindings.MqttV5; +using Neuroglia.AsyncApi.Bindings.Nats; +using Neuroglia.AsyncApi.Bindings.Pulsar; +using Neuroglia.AsyncApi.Bindings.Redis; +using Neuroglia.AsyncApi.Bindings.Sns; +using Neuroglia.AsyncApi.Bindings.Solace; +using Neuroglia.AsyncApi.Bindings.Sqs; +using Neuroglia.AsyncApi.Bindings.Stomp; +using Neuroglia.AsyncApi.Bindings.WebSockets; +using Neuroglia.AsyncApi.v2; + +namespace Neuroglia.AsyncApi.Bindings; /// -/// Represents the object used to configure a 's s +/// Represents the object used to configure a 's s /// [DataContract] public record ServerBindingDefinitionCollection @@ -158,25 +159,25 @@ public record ServerBindingDefinitionCollection /// public override IEnumerable AsEnumerable() { - if (this.Http != null) yield return this.Http; - if (this.Ws != null) yield return this.Ws; - if (this.Kafka != null) yield return this.Kafka; - if (this.AnypointMQ != null) yield return this.AnypointMQ; - if (this.Amqp != null) yield return this.Amqp; - if (this.Amqp1 != null) yield return this.Amqp1; - if (this.Mqtt != null) yield return this.Mqtt; - if (this.Mqtt5 != null) yield return this.Mqtt5; - if (this.Nats != null) yield return this.Nats; - if (this.Jms != null) yield return this.Jms; - if (this.Sns != null) yield return this.Sns; - if (this.Solace != null) yield return this.Solace; - if (this.Sqs != null) yield return this.Sqs; - if (this.Stomp != null) yield return this.Stomp; - if (this.Redis != null) yield return this.Redis; - if (this.Mercure != null) yield return this.Mercure; - if (this.IbmMQ != null) yield return this.IbmMQ; - if (this.GooglePubSub != null) yield return this.GooglePubSub; - if (this.Pulsar != null) yield return this.Pulsar; + if (Http != null) yield return Http; + if (Ws != null) yield return Ws; + if (Kafka != null) yield return Kafka; + if (AnypointMQ != null) yield return AnypointMQ; + if (Amqp != null) yield return Amqp; + if (Amqp1 != null) yield return Amqp1; + if (Mqtt != null) yield return Mqtt; + if (Mqtt5 != null) yield return Mqtt5; + if (Nats != null) yield return Nats; + if (Jms != null) yield return Jms; + if (Sns != null) yield return Sns; + if (Solace != null) yield return Solace; + if (Sqs != null) yield return Sqs; + if (Stomp != null) yield return Stomp; + if (Redis != null) yield return Redis; + if (Mercure != null) yield return Mercure; + if (IbmMQ != null) yield return IbmMQ; + if (GooglePubSub != null) yield return GooglePubSub; + if (Pulsar != null) yield return Pulsar; } } diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsBackoffAlgorithm.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsBackoffAlgorithm.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsBackoffAlgorithm.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsBackoffAlgorithm.cs index 0889a6a..8162b23 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsBackoffAlgorithm.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsBackoffAlgorithm.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Enumerates retry backoff algorithm supported by SNS diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsBindingDefinition.cs similarity index 60% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsBindingDefinition.cs index f4fefa5..7332ddb 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsBindingDefinition.cs @@ -11,7 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Represents the base record for all SNS implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsChannelBindingDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsChannelBindingDefinition.cs index f1eaa1e..ce21094 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsChannelBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Represents the object used to configure a SNS channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsConsumer.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsConsumer.cs similarity index 98% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsConsumer.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsConsumer.cs index 607851d..a484199 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsConsumer.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsConsumer.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Represents an object used to configure an SNS consumer diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsConsumerDeliveryPolicy.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsConsumerDeliveryPolicy.cs similarity index 83% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsConsumerDeliveryPolicy.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsConsumerDeliveryPolicy.cs index 00d51fc..5e7ed33 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsConsumerDeliveryPolicy.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsConsumerDeliveryPolicy.cs @@ -11,7 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Represents an object used to configure an SNS consumer's delivery policy diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsConsumerFilterPolicyScope.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsConsumerFilterPolicyScope.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsConsumerFilterPolicyScope.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsConsumerFilterPolicyScope.cs index 926a7c0..4332ec0 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsConsumerFilterPolicyScope.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsConsumerFilterPolicyScope.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Enumerates all supported SNS consumer filter policy scopes diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsConsumerRedrivePolicy.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsConsumerRedrivePolicy.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsConsumerRedrivePolicy.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsConsumerRedrivePolicy.cs index 81978bc..3d18505 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsConsumerRedrivePolicy.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsConsumerRedrivePolicy.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Represents an object used to configure an SNS consumer's redrive policy diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsIdentifier.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsIdentifier.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsIdentifier.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsIdentifier.cs index 979ad28..b4f2ba1 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsIdentifier.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsIdentifier.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Represents an object used to configure an SNS identifier diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsMessageBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsMessageBindingDefinition.cs index 6296ac7..8b9f4c3 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsMessageBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Represents the object used to configure a SNS message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsOperationBindingDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsOperationBindingDefinition.cs index 1a209ba..e9c8108 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsOperationBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Represents the object used to configure a SNS operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsProtocol.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsProtocol.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsProtocol.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsProtocol.cs index 7a39578..9dc96b3 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsProtocol.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsProtocol.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Enumerates all supported SNS protocols diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsServerBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsServerBindingDefinition.cs index 2db47b2..9a7b6c6 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsServerBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Represents the object used to configure a SNS server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicOrderingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicOrderingDefinition.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicOrderingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicOrderingDefinition.cs index de788eb..cd8cef1 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicOrderingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicOrderingDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Represents an object used to configure topic ordering on an SNS channel diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicOrderingType.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicOrderingType.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicOrderingType.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicOrderingType.cs index c4866e2..24461f2 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicOrderingType.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicOrderingType.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Enumerates all supported SNS topic ordering types diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicSecurityPolicyDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicSecurityPolicyDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicSecurityPolicyDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicSecurityPolicyDefinition.cs index b6f11ce..3bc58ad 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicSecurityPolicyDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicSecurityPolicyDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Represents an object used to configure topic security on an SNS channel diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicSecurityStatementDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicSecurityStatementDefinition.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicSecurityStatementDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicSecurityStatementDefinition.cs index 392fee4..cd18cb6 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicSecurityStatementDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicSecurityStatementDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Represents an object used to configure an SNS topic security statement diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicSecurityStatementEffect.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicSecurityStatementEffect.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicSecurityStatementEffect.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicSecurityStatementEffect.cs index 3fddd76..734e68f 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sns/SnsTopicSecurityStatementEffect.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sns/SnsTopicSecurityStatementEffect.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Sns; +namespace Neuroglia.AsyncApi.Bindings.Sns; /// /// Enumerates all supported SNS topic security statement effects diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceBindingDefinition.cs similarity index 60% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceBindingDefinition.cs index 82597ae..80fb7a4 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceBindingDefinition.cs @@ -11,7 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Solace; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Solace; /// /// Represents the base record for all Solace implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceChannelBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceChannelBindingDefinition.cs index f232353..6f71d3d 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceChannelBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Solace; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Solace; /// /// Represents the object used to configure a Solace channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceDeliveryMode.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceDeliveryMode.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceDeliveryMode.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceDeliveryMode.cs index 8efd4f7..befeb4a 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceDeliveryMode.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceDeliveryMode.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Solace; +namespace Neuroglia.AsyncApi.Bindings.Solace; /// /// Enumerates all supported Solace delivery modes diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceDestinationDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceDestinationDefinition.cs similarity index 78% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceDestinationDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceDestinationDefinition.cs index 640b88e..e7b7db7 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceDestinationDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceDestinationDefinition.cs @@ -11,7 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Solace; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.Bindings.Solace; /// /// Represents an object used to configure a Solace destination diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceDestinationType.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceDestinationType.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceDestinationType.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceDestinationType.cs index a65ce83..b09e31b 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceDestinationType.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceDestinationType.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Solace; +namespace Neuroglia.AsyncApi.Bindings.Solace; /// /// Enumerates all types of Solace destinations diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceMessageBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceMessageBindingDefinition.cs index 21cbd59..ea8908a 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceMessageBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Solace; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Solace; /// /// Represents the object used to configure a JMS message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceOperationBindingDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceOperationBindingDefinition.cs index 8324ec4..0ef600e 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceOperationBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Solace; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Solace; /// /// Represents the object used to configure a JMS operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceQueueAccessType.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceQueueAccessType.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceQueueAccessType.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceQueueAccessType.cs index 76b41eb..25028a6 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceQueueAccessType.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceQueueAccessType.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Solace; +namespace Neuroglia.AsyncApi.Bindings.Solace; /// /// Enumerates all supported Solace queue access types diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceQueueDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceQueueDefinition.cs similarity index 78% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceQueueDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceQueueDefinition.cs index 51bb935..7e2055e 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceQueueDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceQueueDefinition.cs @@ -11,7 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Solace; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.Bindings.Solace; /// /// Represents an object used to configure a Solace queue diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceServerBindingDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceServerBindingDefinition.cs index 8a24a01..6abc3e6 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceServerBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Solace; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Solace; /// /// Represents the object used to configure a JMS server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceTopicDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceTopicDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceTopicDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceTopicDefinition.cs index 1578dab..4538ae9 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Solace/SolaceTopicDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Solace/SolaceTopicDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Solace; +namespace Neuroglia.AsyncApi.Bindings.Solace; /// /// Represents an object used to configure a Solace topic diff --git a/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsBindingDefinition.cs new file mode 100644 index 0000000..6225422 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsBindingDefinition.cs @@ -0,0 +1,50 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Sqs; + +/// +/// Represents the base record for all SQS implementations of the interface +/// +[DataContract] +public abstract record SqsBindingDefinition + : IBindingDefinition +{ + + /// + [IgnoreDataMember, JsonIgnore, YamlIgnore] + public IEnumerable Protocols + { + get + { + yield return AsyncApiProtocol.Sqs; + } + } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsChannelBindingDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsChannelBindingDefinition.cs index 2fe3a87..cf8f3e6 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsChannelBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sqs; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Sqs; /// /// Represents the object used to configure a SQS channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsDeduplicationScope.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsDeduplicationScope.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsDeduplicationScope.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsDeduplicationScope.cs index 1c4aa52..2af671d 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsDeduplicationScope.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsDeduplicationScope.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Sqs; +namespace Neuroglia.AsyncApi.Bindings.Sqs; /// /// Enumerates all supported SQS deduplication scopes diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsFifoThroughputLimit.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsFifoThroughputLimit.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsFifoThroughputLimit.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsFifoThroughputLimit.cs index d3dc753..463e94a 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsFifoThroughputLimit.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsFifoThroughputLimit.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Sqs; +namespace Neuroglia.AsyncApi.Bindings.Sqs; /// /// Enumerates all supported SQS FIFO throughput limits diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsIdentifier.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsIdentifier.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsIdentifier.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsIdentifier.cs index cda862a..ca05907 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsIdentifier.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsIdentifier.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sqs; +namespace Neuroglia.AsyncApi.Bindings.Sqs; /// /// Represents an SQS identifier diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsMessageBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsMessageBindingDefinition.cs index 6035597..9e50452 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsMessageBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sqs; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Sqs; /// /// Represents the object used to configure a SQS message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsOperationBindingDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsOperationBindingDefinition.cs index 972eaf0..6abbe74 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsOperationBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sqs; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Sqs; /// /// Represents the object used to configure a SQS operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsQueueDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsQueueDefinition.cs similarity index 89% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsQueueDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsQueueDefinition.cs index 1e67bfc..32ba81d 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsQueueDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsQueueDefinition.cs @@ -11,7 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sqs; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.Bindings.Sqs; /// /// Represents the object used to configure an SQS queue diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsQueueRedrivePolicyDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsQueueRedrivePolicyDefinition.cs similarity index 68% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsQueueRedrivePolicyDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsQueueRedrivePolicyDefinition.cs index c8b7d6d..4385013 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsQueueRedrivePolicyDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsQueueRedrivePolicyDefinition.cs @@ -11,9 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings.Sns; -namespace Neuroglia.AsyncApi.v2.Bindings.Sqs; +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings.Sns; + +namespace Neuroglia.AsyncApi.Bindings.Sqs; /// /// Represents an object used to configure the redrive policy of an SQS queue diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsQueueSecurityPolicyDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsQueueSecurityPolicyDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsQueueSecurityPolicyDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsQueueSecurityPolicyDefinition.cs index 515289b..31d0add 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsQueueSecurityPolicyDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsQueueSecurityPolicyDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sqs; +namespace Neuroglia.AsyncApi.Bindings.Sqs; /// /// Represents an object used to configure the security policy of an SQS queue diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsServerBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsServerBindingDefinition.cs index 4908c85..d57eb69 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsServerBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sqs; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Sqs; /// /// Represents the object used to configure a SQS server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsTopicSecurityStatementDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsTopicSecurityStatementDefinition.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsTopicSecurityStatementDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsTopicSecurityStatementDefinition.cs index 36b58e1..03edc06 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsTopicSecurityStatementDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsTopicSecurityStatementDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sqs; +namespace Neuroglia.AsyncApi.Bindings.Sqs; /// /// Represents an object used to configure an SQS topic security statement diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsTopicSecurityStatementEffect.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsTopicSecurityStatementEffect.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsTopicSecurityStatementEffect.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsTopicSecurityStatementEffect.cs index 3b8397b..45ac43d 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsTopicSecurityStatementEffect.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Sqs/SqsTopicSecurityStatementEffect.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2.Bindings.Sqs; +namespace Neuroglia.AsyncApi.Bindings.Sqs; /// /// Enumerates all supported SNS topic security statement effects diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompBindingDefinition.cs similarity index 60% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompBindingDefinition.cs index 477744e..2a1e480 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompBindingDefinition.cs @@ -11,7 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Stomp; + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Stomp; /// /// Represents the base record for all STOMP implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompChannelBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompChannelBindingDefinition.cs index 1e2cffe..8c06641 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompChannelBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Stomp; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Stomp; /// /// Represents the object used to configure a STOMP channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompMessageBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompMessageBindingDefinition.cs index f201efa..1abecae 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompMessageBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Stomp; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Stomp; /// /// Represents the object used to configure a STOMP message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompOperationBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompOperationBindingDefinition.cs index 52c16eb..4174a92 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompOperationBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Stomp; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Stomp; /// /// Represents the object used to configure a STOMP operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompServerBindingDefinition.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompServerBindingDefinition.cs index 2f32cb8..8109d79 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Stomp/StompServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/Stomp/StompServerBindingDefinition.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Stomp; +using Neuroglia.AsyncApi.Bindings; + +namespace Neuroglia.AsyncApi.Bindings.Stomp; /// /// Represents the object used to configure a STOMP server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsBindingDefinition.cs similarity index 89% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsBindingDefinition.cs index 3c2a3fd..aa7aa61 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsBindingDefinition.cs @@ -11,10 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.WebSockets; +namespace Neuroglia.AsyncApi.Bindings.WebSockets; /// /// Represents the base record for all Websocket implementations of the interface diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsChannelBindingDefinition.cs similarity index 94% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsChannelBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsChannelBindingDefinition.cs index a15e18b..a24dd6d 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsChannelBindingDefinition.cs @@ -12,10 +12,10 @@ // limitations under the License. using Json.Schema; -using Neuroglia.AsyncApi.v2.Bindings; -using Neuroglia.AsyncApi.v2.Bindings.Http; +using Neuroglia.AsyncApi.Bindings; +using Neuroglia.AsyncApi.Bindings.Http; -namespace Neuroglia.AsyncApi.v2.Bindings.WebSockets; +namespace Neuroglia.AsyncApi.Bindings.WebSockets; /// /// Represents the object used to configure an WebSocket channel binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsMessageBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsMessageBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsMessageBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsMessageBindingDefinition.cs index 7e09505..69c91c6 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsMessageBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsMessageBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.WebSockets; +namespace Neuroglia.AsyncApi.Bindings.WebSockets; /// /// Represents the object used to configure a WebSocket message binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsOperationBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsOperationBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsOperationBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsOperationBindingDefinition.cs index aaca727..4cd9ef7 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsOperationBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsOperationBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.WebSockets; +namespace Neuroglia.AsyncApi.Bindings.WebSockets; /// /// Represents the object used to configure a WebSocket operation binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsServerBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsServerBindingDefinition.cs similarity index 90% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsServerBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsServerBindingDefinition.cs index 9948a92..b84402c 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/WebSockets/WsServerBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/WebSockets/WsServerBindingDefinition.cs @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.v2.Bindings.WebSockets; +namespace Neuroglia.AsyncApi.Bindings.WebSockets; /// /// Represents the object used to configure an WebSocket server binding diff --git a/src/Neuroglia.AsyncApi.Core/v2/ContactDefinition.cs b/src/Neuroglia.AsyncApi.Core/ContactDefinition.cs similarity index 98% rename from src/Neuroglia.AsyncApi.Core/v2/ContactDefinition.cs rename to src/Neuroglia.AsyncApi.Core/ContactDefinition.cs index d96ccd2..cd8816a 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/ContactDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/ContactDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Represents an object used to provide contact information for the exposed API diff --git a/src/Neuroglia.AsyncApi.Core/v2/CorrelationIdDefinition.cs b/src/Neuroglia.AsyncApi.Core/CorrelationIdDefinition.cs similarity index 98% rename from src/Neuroglia.AsyncApi.Core/v2/CorrelationIdDefinition.cs rename to src/Neuroglia.AsyncApi.Core/CorrelationIdDefinition.cs index 9f006c0..a3bbd48 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/CorrelationIdDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/CorrelationIdDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Represents an object used to define an Async API correlation ID diff --git a/src/Neuroglia.AsyncApi.Core/v2/ExternalDocumentationDefinition.cs b/src/Neuroglia.AsyncApi.Core/ExternalDocumentationDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/ExternalDocumentationDefinition.cs rename to src/Neuroglia.AsyncApi.Core/ExternalDocumentationDefinition.cs index d598932..99b92c9 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/ExternalDocumentationDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/ExternalDocumentationDefinition.cs @@ -11,13 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Represents an object used to define a reference to an external documentation /// [DataContract] public record ExternalDocumentationDefinition + : ReferenceableComponentDefinition { /// diff --git a/src/Neuroglia.AsyncApi.Core/v2/HttpApiKeyLocation.cs b/src/Neuroglia.AsyncApi.Core/HttpApiKeyLocation.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/HttpApiKeyLocation.cs rename to src/Neuroglia.AsyncApi.Core/HttpApiKeyLocation.cs index bf28de0..cecf1a5 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/HttpApiKeyLocation.cs +++ b/src/Neuroglia.AsyncApi.Core/HttpApiKeyLocation.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Exposes constants about HTTP API key locations diff --git a/src/Neuroglia.AsyncApi.Core/v2/IReferenceable.cs b/src/Neuroglia.AsyncApi.Core/IReferenceable.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/IReferenceable.cs rename to src/Neuroglia.AsyncApi.Core/IReferenceable.cs index 36d289e..f3f4433 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/IReferenceable.cs +++ b/src/Neuroglia.AsyncApi.Core/IReferenceable.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Defines the fundamentals of a referenceable component diff --git a/src/Neuroglia.AsyncApi.Core/v2/LicenseDefinition.cs b/src/Neuroglia.AsyncApi.Core/LicenseDefinition.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/LicenseDefinition.cs rename to src/Neuroglia.AsyncApi.Core/LicenseDefinition.cs index 7fdc76f..55659d4 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/LicenseDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/LicenseDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Represents an object used to provide license information for the exposed API diff --git a/src/Neuroglia.AsyncApi.Core/v2/OAuthFlowDefinition.cs b/src/Neuroglia.AsyncApi.Core/OAuthFlowDefinition.cs similarity index 98% rename from src/Neuroglia.AsyncApi.Core/v2/OAuthFlowDefinition.cs rename to src/Neuroglia.AsyncApi.Core/OAuthFlowDefinition.cs index 15305df..fe67b03 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/OAuthFlowDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/OAuthFlowDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Represents an object used to define a supported OAuth Flow diff --git a/src/Neuroglia.AsyncApi.Core/v2/OAuthFlowDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/OAuthFlowDefinitionCollection.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/OAuthFlowDefinitionCollection.cs rename to src/Neuroglia.AsyncApi.Core/OAuthFlowDefinitionCollection.cs index ddcf0bb..6131354 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/OAuthFlowDefinitionCollection.cs +++ b/src/Neuroglia.AsyncApi.Core/OAuthFlowDefinitionCollection.cs @@ -11,9 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System.Collections; - -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Represents a collection of s diff --git a/src/Neuroglia.AsyncApi.Core/v2/ReferenceableComponentDefinition.cs b/src/Neuroglia.AsyncApi.Core/ReferenceableComponentDefinition.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/ReferenceableComponentDefinition.cs rename to src/Neuroglia.AsyncApi.Core/ReferenceableComponentDefinition.cs index 163aad7..9c9aac6 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/ReferenceableComponentDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/ReferenceableComponentDefinition.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Represents the base record for all Async API components diff --git a/src/Neuroglia.AsyncApi.Core/v2/RuntimeExpression.cs b/src/Neuroglia.AsyncApi.Core/RuntimeExpression.cs similarity index 99% rename from src/Neuroglia.AsyncApi.Core/v2/RuntimeExpression.cs rename to src/Neuroglia.AsyncApi.Core/RuntimeExpression.cs index cea63fd..e02eb29 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/RuntimeExpression.cs +++ b/src/Neuroglia.AsyncApi.Core/RuntimeExpression.cs @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Represents a parsed Async API runtime expression diff --git a/src/Neuroglia.AsyncApi.Core/v2/RuntimeExpressionSource.cs b/src/Neuroglia.AsyncApi.Core/RuntimeExpressionSource.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/RuntimeExpressionSource.cs rename to src/Neuroglia.AsyncApi.Core/RuntimeExpressionSource.cs index 6cbd5dd..a5f47fc 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/RuntimeExpressionSource.cs +++ b/src/Neuroglia.AsyncApi.Core/RuntimeExpressionSource.cs @@ -14,7 +14,7 @@ using Neuroglia.Serialization.Json.Converters; using System.ComponentModel; -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Enumerates all supported runtime expression sources diff --git a/src/Neuroglia.AsyncApi.Core/v2/SecuritySchemeType.cs b/src/Neuroglia.AsyncApi.Core/SecuritySchemeType.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/SecuritySchemeType.cs rename to src/Neuroglia.AsyncApi.Core/SecuritySchemeType.cs index 6478d40..61410f4 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/SecuritySchemeType.cs +++ b/src/Neuroglia.AsyncApi.Core/SecuritySchemeType.cs @@ -11,10 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.Serialization.Json.Converters; -using System.ComponentModel; - -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Enumerates all supported security schemes diff --git a/src/Neuroglia.AsyncApi.Core/v2/VariableDefinition.cs b/src/Neuroglia.AsyncApi.Core/ServerVariableDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/v2/VariableDefinition.cs rename to src/Neuroglia.AsyncApi.Core/ServerVariableDefinition.cs index 09d1374..c88caa0 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/VariableDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/ServerVariableDefinition.cs @@ -11,13 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Represents an object used to describe a Server Variable for server URL template substitution. /// [DataContract] -public record VariableDefinition +public record ServerVariableDefinition + : ReferenceableComponentDefinition { /// diff --git a/src/Neuroglia.AsyncApi.Core/v2/TagDefinition.cs b/src/Neuroglia.AsyncApi.Core/TagDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/v2/TagDefinition.cs rename to src/Neuroglia.AsyncApi.Core/TagDefinition.cs index 8c18003..2462610 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/TagDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/TagDefinition.cs @@ -11,13 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2; +namespace Neuroglia.AsyncApi; /// /// Represents an object used to define a tag assigned to an Async API component /// [DataContract] public record TagDefinition + : ReferenceableComponentDefinition { /// diff --git a/src/Neuroglia.AsyncApi.Core/Usings.cs b/src/Neuroglia.AsyncApi.Core/Usings.cs index c0501a5..570362e 100644 --- a/src/Neuroglia.AsyncApi.Core/Usings.cs +++ b/src/Neuroglia.AsyncApi.Core/Usings.cs @@ -11,7 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +global using Json.Schema; +global using Neuroglia.AsyncApi.Bindings; +global using Neuroglia.Serialization.Json.Converters; +global using System.Collections; +global using System.ComponentModel; global using System.ComponentModel.DataAnnotations; global using System.Runtime.Serialization; global using System.Text.Json.Serialization; -global using YamlDotNet.Serialization; \ No newline at end of file +global using YamlDotNet.Core; +global using YamlDotNet.Serialization; diff --git a/src/Neuroglia.AsyncApi.Core/v2/ApiInfo.cs b/src/Neuroglia.AsyncApi.Core/v2/V2ApiInfo.cs similarity index 97% rename from src/Neuroglia.AsyncApi.Core/v2/ApiInfo.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2ApiInfo.cs index eef2154..d8cf295 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/ApiInfo.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2ApiInfo.cs @@ -17,7 +17,7 @@ namespace Neuroglia.AsyncApi.v2; /// Represents an object that provides metadata about the API. The metadata can be used by the clients if needed /// [DataContract] -public record ApiInfo +public record V2ApiInfo { /// @@ -59,6 +59,6 @@ public record ApiInfo public virtual LicenseDefinition? License { get; set; } /// - public override string ToString() => Title; + public override string ToString() => this.Title; } diff --git a/src/Neuroglia.AsyncApi.Core/v2/AsyncApiDocument.cs b/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs similarity index 77% rename from src/Neuroglia.AsyncApi.Core/v2/AsyncApiDocument.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs index b50b943..a58c76e 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/AsyncApiDocument.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs @@ -11,15 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -using YamlDotNet.Core; - namespace Neuroglia.AsyncApi.v2; /// /// Represents an Async API version 2 document /// [DataContract] -public record AsyncApiDocument +public record V2AsyncApiDocument { /// @@ -45,13 +43,13 @@ public record AsyncApiDocument /// [Required] [DataMember(Order = 3, Name = "info"), JsonPropertyOrder(3), JsonPropertyName("info"), YamlMember(Order = 3, Alias = "info")] - public virtual ApiInfo Info { get; set; } = null!; + public virtual V2ApiInfo Info { get; set; } = null!; /// /// Gets/sets a containing name/configuration mappings for the application's servers /// [DataMember(Order = 4, Name = "servers"), JsonPropertyOrder(4), JsonPropertyName("servers"), YamlMember(Order = 4, Alias = "servers")] - public virtual EquatableDictionary? Servers { get; set; } + public virtual EquatableDictionary? Servers { get; set; } /// /// Gets/sets the default content type to use when encoding/decoding a message's payload. @@ -64,13 +62,13 @@ public record AsyncApiDocument /// [Required, MinLength(1)] [DataMember(Order = 6, Name = "channels"), JsonPropertyOrder(6), JsonPropertyName("channels"), YamlMember(Order = 6, Alias = "channels")] - public virtual EquatableDictionary Channels { get; set; } = null!; + public virtual EquatableDictionary Channels { get; set; } = null!; /// /// Gets/sets an object used to hold various schemas for the specification. /// [DataMember(Order = 7, Name = "components"), JsonPropertyOrder(7), JsonPropertyName("components"), YamlMember(Order = 7, Alias = "components")] - public virtual ComponentDefinitionCollection? Components { get; set; } + public virtual V2ComponentDefinitionCollection? Components { get; set; } /// /// Gets/sets a of tags used by the specification with additional metadata. Each tag name in the list MUST be unique. @@ -85,31 +83,31 @@ public record AsyncApiDocument public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } /// - /// Attempts to get the with the specified id + /// Attempts to get the with the specified id /// - /// The id of the to get - /// The resulting , if any - /// The name of the the belongs to, if any - /// A boolean indicating whether or not the with the specified id could be found - public virtual bool TryGetOperation(string operationId, out OperationDefinition? operation, out string? channelName) + /// The id of the to get + /// The resulting , if any + /// The name of the the belongs to, if any + /// A boolean indicating whether or not the with the specified id could be found + public virtual bool TryGetOperation(string operationId, out V2OperationDefinition? operation, out string? channelName) { if (string.IsNullOrWhiteSpace(operationId)) throw new ArgumentNullException(nameof(operationId)); operation = null; channelName = null; var channel = Channels?.FirstOrDefault(c => c.Value.DefinesOperationWithId(operationId)); - if (!channel.HasValue || channel.Value.Equals(default(KeyValuePair))) return false; + if (!channel.HasValue || channel.Value.Equals(default(KeyValuePair))) return false; operation = channel.Value.Value.GetOperationById(operationId); channelName = channel.Value.Key; return true; } /// - /// Attempts to get the with the specified id + /// Attempts to get the with the specified id /// - /// The id of the to get - /// The resulting , if any - /// A boolean indicating whether or not the with the specified id could be found - public virtual bool TryGetOperation(string operationId, out OperationDefinition? operation) + /// The id of the to get + /// The resulting , if any + /// A boolean indicating whether or not the with the specified id could be found + public virtual bool TryGetOperation(string operationId, out V2OperationDefinition? operation) { if (string.IsNullOrWhiteSpace(operationId)) throw new ArgumentNullException(nameof(operationId)); @@ -117,6 +115,6 @@ public virtual bool TryGetOperation(string operationId, out OperationDefinition? } /// - public override string? ToString() => Info == null || string.IsNullOrWhiteSpace(Info.Title) ? Id : Info?.Title; + public override string? ToString() => this.Info == null || string.IsNullOrWhiteSpace(this.Info.Title) ? Id : this.Info?.Title; } diff --git a/src/Neuroglia.AsyncApi.Core/v2/ChannelDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2ChannelDefinition.cs similarity index 61% rename from src/Neuroglia.AsyncApi.Core/v2/ChannelDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2ChannelDefinition.cs index fce6b1b..71e24d2 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/ChannelDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2ChannelDefinition.cs @@ -11,15 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; - namespace Neuroglia.AsyncApi.v2; /// /// Represents an object used to define an Async API channel /// [DataContract] -public record ChannelDefinition +public record V2ChannelDefinition : ReferenceableComponentDefinition { @@ -33,43 +31,43 @@ public record ChannelDefinition /// Gets/sets a definition of the SUBSCRIBE operation, which defines the messages produced by the application and sent to the channel. /// [DataMember(Order = 2, Name = "subscribe"), JsonPropertyOrder(2), JsonPropertyName("subscribe"), YamlMember(Order = 2, Alias = "subscribe")] - public virtual OperationDefinition? Subscribe { get; set; } + public virtual V2OperationDefinition? Subscribe { get; set; } /// /// Gets/sets a definition of the PUBLISH operation, which defines the messages consumed by the application from the channel. /// [DataMember(Order = 3, Name = "publish"), JsonPropertyOrder(3), JsonPropertyName("publish"), YamlMember(Order = 3, Alias = "publish")] - public virtual OperationDefinition? Publish { get; set; } + public virtual V2OperationDefinition? Publish { get; set; } /// /// Gets/sets a of the parameters included in the channel name. It SHOULD be present only when using channels with expressions (as defined by RFC 6570 section 2.2). /// [DataMember(Order = 4, Name = "parameters"), JsonPropertyOrder(4), JsonPropertyName("parameters"), YamlMember(Order = 4, Alias = "parameters")] - public virtual EquatableDictionary? Parameters { get; set; } + public virtual EquatableDictionary? Parameters { get; set; } /// - /// Gets/sets an object used to configure the 's s + /// Gets/sets an object used to configure the 's s /// [DataMember(Order = 5, Name = "bindings"), JsonPropertyOrder(5), JsonPropertyName("bindings"), YamlMember(Order = 5, Alias = "bindings")] public virtual ChannelBindingDefinitionCollection? Bindings { get; set; } /// - /// Gets a boolean indicating whether or not the defines an of type + /// Gets a boolean indicating whether or not the defines an of type /// [IgnoreDataMember, JsonIgnore, YamlIgnore] - public virtual bool DefinesSubscribeOperation => DefinesOperationOfType(OperationType.Subscribe); + public virtual bool DefinesSubscribeOperation => DefinesOperationOfType(V2OperationType.Subscribe); /// - /// Gets a boolean indicating whether or not the defines an of type + /// Gets a boolean indicating whether or not the defines an of type /// [IgnoreDataMember, JsonIgnore, YamlIgnore] - public virtual bool DefinesPublishOperation => DefinesOperationOfType(OperationType.Publish); + public virtual bool DefinesPublishOperation => DefinesOperationOfType(V2OperationType.Publish); /// - /// Determines whether or not the defines an with the specified id + /// Determines whether or not the defines an with the specified id /// /// The id of the operation to check - /// A boolean indicating whether or not the defines an with the specified id + /// A boolean indicating whether or not the defines an with the specified id public virtual bool DefinesOperationWithId(string operationId) { if (string.IsNullOrWhiteSpace(operationId)) throw new ArgumentNullException(nameof(operationId)); @@ -77,26 +75,26 @@ public virtual bool DefinesOperationWithId(string operationId) } /// - /// Determines whether or not the defines an of the specified type + /// Determines whether or not the defines an of the specified type /// /// The type of the operation to check - /// A boolean indicating whether or not the defines an of the specified type - public virtual bool DefinesOperationOfType(OperationType type) + /// A boolean indicating whether or not the defines an of the specified type + public virtual bool DefinesOperationOfType(V2OperationType type) { return type switch { - OperationType.Publish => Publish != null, - OperationType.Subscribe => Subscribe != null, + V2OperationType.Publish => Publish != null, + V2OperationType.Subscribe => Subscribe != null, _ => throw new NotSupportedException($"The specified operation type '{type}' is not supported"), }; } /// - /// Gets the with the specified id + /// Gets the with the specified id /// - /// The id of the to get - /// The with the specified id, if any - public virtual OperationDefinition? GetOperationById(string operationId) + /// The id of the to get + /// The with the specified id, if any + public virtual V2OperationDefinition? GetOperationById(string operationId) { if (string.IsNullOrWhiteSpace(operationId)) throw new ArgumentNullException(nameof(operationId)); if (Publish?.OperationId == operationId) return Publish; @@ -105,12 +103,12 @@ public virtual bool DefinesOperationOfType(OperationType type) } /// - /// Attempts to retrieve an by id + /// Attempts to retrieve an by id /// - /// The id of the to get - /// The with the specified id - /// A boolean indicating whether or not the with the specified id could be found - public virtual bool TryGetOperationById(string operationId, out OperationDefinition? operation) + /// The id of the to get + /// The with the specified id + /// A boolean indicating whether or not the with the specified id could be found + public virtual bool TryGetOperationById(string operationId, out V2OperationDefinition? operation) { if (string.IsNullOrWhiteSpace(operationId)) throw new ArgumentNullException(nameof(operationId)); operation = GetOperationById(operationId); @@ -118,27 +116,27 @@ public virtual bool TryGetOperationById(string operationId, out OperationDefinit } /// - /// Gets the of the specified type + /// Gets the of the specified type /// - /// The type of the to get - /// The of the specified type, if any - public virtual OperationDefinition? GetOperationByType(OperationType type) + /// The type of the to get + /// The of the specified type, if any + public virtual V2OperationDefinition? GetOperationByType(V2OperationType type) { return type switch { - OperationType.Publish => Publish, - OperationType.Subscribe => Subscribe, + V2OperationType.Publish => Publish, + V2OperationType.Subscribe => Subscribe, _ => throw new NotSupportedException($"The specified operation type '{type}' is not supported"), }; } /// - /// Attempts to retrieve an by type + /// Attempts to retrieve an by type /// - /// The type of the to get - /// The of the specified type - /// A boolean indicating whether or not the of the specified type could be found - public virtual bool TryGetOperationById(OperationType type, out OperationDefinition? operation) + /// The type of the to get + /// The of the specified type + /// A boolean indicating whether or not the of the specified type could be found + public virtual bool TryGetOperationById(V2OperationType type, out V2OperationDefinition? operation) { operation = GetOperationByType(type); return operation != null; diff --git a/src/Neuroglia.AsyncApi.Core/v2/ComponentDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/v2/V2ComponentDefinitionCollection.cs similarity index 84% rename from src/Neuroglia.AsyncApi.Core/v2/ComponentDefinitionCollection.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2ComponentDefinitionCollection.cs index b0276d8..3b2aa6c 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/ComponentDefinitionCollection.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2ComponentDefinitionCollection.cs @@ -11,9 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Json.Schema; -using Neuroglia.AsyncApi.v2.Bindings; - namespace Neuroglia.AsyncApi.v2; /// @@ -21,7 +18,7 @@ namespace Neuroglia.AsyncApi.v2; /// All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. /// [DataContract] -public record ComponentDefinitionCollection +public record V2ComponentDefinitionCollection { /// @@ -31,22 +28,22 @@ public record ComponentDefinitionCollection public virtual EquatableDictionary? Schemas { get; set; } /// - /// Gets/sets a used to hold reusable s + /// Gets/sets a used to hold reusable s /// [DataMember(Order = 2, Name = "messages"), JsonPropertyOrder(2), JsonPropertyName("messages"), YamlMember(Order = 2, Alias = "messages")] - public virtual EquatableDictionary? Messages { get; set; } + public virtual EquatableDictionary? Messages { get; set; } /// - /// Gets/sets a used to hold reusable s + /// Gets/sets a used to hold reusable s /// [DataMember(Order = 3, Name = "securitySchemes"), JsonPropertyOrder(3), JsonPropertyName("securitySchemes"), YamlMember(Order = 3, Alias = "securitySchemes")] - public virtual EquatableDictionary? SecuritySchemes { get; set; } + public virtual EquatableDictionary? SecuritySchemes { get; set; } /// - /// Gets/sets a used to hold reusable s + /// Gets/sets a used to hold reusable s /// [DataMember(Order = 4, Name = "parameters"), JsonPropertyOrder(4), JsonPropertyName("parameters"), YamlMember(Order = 4, Alias = "parameters")] - public virtual EquatableDictionary? Parameters { get; set; } + public virtual EquatableDictionary? Parameters { get; set; } /// /// Gets/sets a used to hold reusable s @@ -55,16 +52,16 @@ public record ComponentDefinitionCollection public virtual EquatableDictionary? CorrelationIds { get; set; } /// - /// Gets/sets a used to hold reusable s + /// Gets/sets a used to hold reusable s /// [DataMember(Order = 6, Name = "operationTraits"), JsonPropertyOrder(6), JsonPropertyName("operationTraits"), YamlMember(Order = 6, Alias = "operationTraits")] - public virtual EquatableDictionary? OperationTraits { get; set; } + public virtual EquatableDictionary? OperationTraits { get; set; } /// - /// Gets/sets a used to hold reusable s + /// Gets/sets a used to hold reusable s /// [DataMember(Order = 7, Name = "messageTraits"), JsonPropertyOrder(7), JsonPropertyName("messageTraits"), YamlMember(Order = 7, Alias = "messageTraits")] - public virtual EquatableDictionary? MessageTraits { get; set; } + public virtual EquatableDictionary? MessageTraits { get; set; } /// /// Gets/sets a used to hold reusable s diff --git a/src/Neuroglia.AsyncApi.Core/v2/MessageDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2MessageDefinition.cs similarity index 82% rename from src/Neuroglia.AsyncApi.Core/v2/MessageDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2MessageDefinition.cs index 1b91aaa..434b4da 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/MessageDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2MessageDefinition.cs @@ -17,12 +17,12 @@ namespace Neuroglia.AsyncApi.v2; /// Represents an object used to define a Async API operation message /// [DataContract] -public record MessageDefinition - : MessageTraitDefinition +public record V2MessageDefinition + : V2MessageTraitDefinition { /// - /// Gets/sets the definition of the message payload. It can be of any type but defaults to Schema object. It must match the , including encoding type - e.g Avro should be inlined as either a YAML or JSON object NOT a string to be parsed as YAML or JSON. + /// Gets/sets the definition of the message payload. It can be of any type but defaults to Schema object. It must match the , including encoding type - e.g Avro should be inlined as either a YAML or JSON object NOT a string to be parsed as YAML or JSON. /// [DataMember(Order = 1, Name = "payload"), JsonPropertyOrder(1), JsonPropertyName("payload"), YamlMember(Order = 1, Alias = "payload")] public virtual object? Payload { get; set; } @@ -31,6 +31,6 @@ public record MessageDefinition /// Gets/sets a of traits to apply to the message object. Traits MUST be merged into the message object using the JSON Merge Patch algorithm in the same order they are defined here. /// [DataMember(Order = 2, Name = "traits"), JsonPropertyOrder(2), JsonPropertyName("traits"), YamlMember(Order = 2, Alias = "traits")] - public virtual EquatableList? Traits { get; set; } + public virtual EquatableList? Traits { get; set; } } diff --git a/src/Neuroglia.AsyncApi.Core/v2/MessageTraitDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2MessageTraitDefinition.cs similarity index 94% rename from src/Neuroglia.AsyncApi.Core/v2/MessageTraitDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2MessageTraitDefinition.cs index 1506199..4d55420 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/MessageTraitDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2MessageTraitDefinition.cs @@ -11,16 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Json.Schema; -using Neuroglia.AsyncApi.v2.Bindings; - namespace Neuroglia.AsyncApi.v2; /// /// Represents an object used to define a Async API operation message trait /// [DataContract] -public record MessageTraitDefinition +public record V2MessageTraitDefinition : ReferenceableComponentDefinition { @@ -45,7 +42,7 @@ public record MessageTraitDefinition public virtual string? SchemaFormat { get; set; } /// - /// Gets/sets the content type to use when encoding/decoding a message's payload. The value MUST be a specific media type (e.g. application/json). When omitted, the value MUST be the one specified on the property. + /// Gets/sets the content type to use when encoding/decoding a message's payload. The value MUST be a specific media type (e.g. application/json). When omitted, the value MUST be the one specified on the property. /// [DataMember(Order = 4, Name = "contentType"), JsonPropertyOrder(4), JsonPropertyName("contentType"), YamlMember(Order = 4, Alias = "contentType")] public virtual string? ContentType { get; set; } @@ -87,7 +84,7 @@ public record MessageTraitDefinition public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } /// - /// Gets/sets an object used to configure the 's s + /// Gets/sets an object used to configure the 's s /// [DataMember(Order = 11, Name = "bindings"), JsonPropertyOrder(11), JsonPropertyName("bindings"), YamlMember(Order = 11, Alias = "bindings")] public virtual MessageBindingDefinitionCollection? Bindings { get; set; } diff --git a/src/Neuroglia.AsyncApi.Core/v2/OperationDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2OperationDefinition.cs similarity index 86% rename from src/Neuroglia.AsyncApi.Core/v2/OperationDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2OperationDefinition.cs index 7f10053..ce9e05b 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/OperationDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2OperationDefinition.cs @@ -17,20 +17,20 @@ namespace Neuroglia.AsyncApi.v2; /// Represents an object used to define a Async API operation /// [DataContract] -public record OperationDefinition - : OperationTraitDefinition +public record V2OperationDefinition + : V2OperationTraitDefinition { /// /// Gets/sets a of traits to apply to the operation object. Traits MUST be merged into the operation object using the JSON Merge Patch algorithm in the same order they are defined here. /// [DataMember(Order = 1, Name = "traits"), JsonPropertyOrder(1), JsonPropertyName("traits"), YamlMember(Order = 1, Alias = "traits")] - public virtual EquatableList? Traits { get; set; } + public virtual EquatableList? Traits { get; set; } /// /// Gets/sets a definition of the message(s) that will be published or received on this channel. /// [DataMember(Order = 2, Name = "message"), JsonPropertyOrder(2), JsonPropertyName("message"), YamlMember(Order = 2, Alias = "message")] - public virtual OperationMessageDefinition? Message { get; set; } + public virtual V2OperationMessageDefinition? Message { get; set; } } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v2/OperationMessageDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2OperationMessageDefinition.cs similarity index 72% rename from src/Neuroglia.AsyncApi.Core/v2/OperationMessageDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2OperationMessageDefinition.cs index 15e0622..28dee8b 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/OperationMessageDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2OperationMessageDefinition.cs @@ -17,24 +17,24 @@ namespace Neuroglia.AsyncApi.v2; /// Represents an object used to define the message(s) supported by the operation /// [DataContract] -public record OperationMessageDefinition - : MessageDefinition +public record V2OperationMessageDefinition + : V2MessageDefinition { /// /// Gets/sets a list, if any, of all messages supported by the operation /// [DataMember(Order = 99, Name = "oneOf"), JsonPropertyOrder(99), JsonPropertyName("oneOf"), YamlMember(Order = 99, Alias = "oneOf")] - public virtual EquatableList? OneOf { get; set; } + public virtual EquatableList? OneOf { get; set; } /// - /// Creates a new based on the specified + /// Creates a new based on the specified /// - /// The to create a new for - /// A new - public static OperationMessageDefinition From(MessageDefinition messageDefinition) + /// The to create a new for + /// A new + public static V2OperationMessageDefinition From(V2MessageDefinition messageDefinition) { - if (messageDefinition is OperationMessageDefinition operationMessageDefinition) return operationMessageDefinition; + if (messageDefinition is V2OperationMessageDefinition operationMessageDefinition) return operationMessageDefinition; return new() { Bindings = messageDefinition.Bindings, diff --git a/src/Neuroglia.AsyncApi.Core/v2/OperationTraitDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2OperationTraitDefinition.cs similarity index 93% rename from src/Neuroglia.AsyncApi.Core/v2/OperationTraitDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2OperationTraitDefinition.cs index 8f15f56..5c3a4b1 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/OperationTraitDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2OperationTraitDefinition.cs @@ -11,15 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; - namespace Neuroglia.AsyncApi.v2; /// /// Represents an object used to define a Async API operation trait /// [DataContract] -public record OperationTraitDefinition +public record V2OperationTraitDefinition : ReferenceableComponentDefinition { @@ -54,7 +52,7 @@ public record OperationTraitDefinition public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } /// - /// Gets/sets an object used to configure the 's s + /// Gets/sets an object used to configure the 's s /// [DataMember(Order = 6, Name = "bindings"), JsonPropertyOrder(6), JsonPropertyName("bindings"), YamlMember(Order = 6, Alias = "bindings")] public virtual OperationBindingDefinitionCollection? Bindings { get; set; } diff --git a/src/Neuroglia.AsyncApi.Core/v2/OperationType.cs b/src/Neuroglia.AsyncApi.Core/v2/V2OperationType.cs similarity index 91% rename from src/Neuroglia.AsyncApi.Core/v2/OperationType.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2OperationType.cs index 95ba7f8..0964a0d 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/OperationType.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2OperationType.cs @@ -11,9 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.Serialization.Json.Converters; -using System.ComponentModel; - namespace Neuroglia.AsyncApi.v2; /// @@ -21,7 +18,7 @@ namespace Neuroglia.AsyncApi.v2; /// [JsonConverter(typeof(StringEnumConverter))] [TypeConverter(typeof(EnumMemberTypeConverter))] -public enum OperationType +public enum V2OperationType { /// /// Indicates a PUB operation diff --git a/src/Neuroglia.AsyncApi.Core/v2/ParameterDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2ParameterDefinition.cs similarity index 94% rename from src/Neuroglia.AsyncApi.Core/v2/ParameterDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2ParameterDefinition.cs index 68b0e97..e2669d2 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/ParameterDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2ParameterDefinition.cs @@ -11,15 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Json.Schema; - namespace Neuroglia.AsyncApi.v2; /// /// Represents an object used to define an Async API parameter /// [DataContract] -public record ParameterDefinition +public record V2ParameterDefinition : ReferenceableComponentDefinition { @@ -38,7 +36,7 @@ public record ParameterDefinition public virtual string? Description { get; set; } /// - /// Gets/sets the 's + /// Gets/sets the 's /// [DataMember(Order = 3, Name = "schema"), JsonPropertyOrder(3), JsonPropertyName("schema"), YamlMember(Order = 3, Alias = "schema")] public virtual JsonSchema? Schema { get; set; } diff --git a/src/Neuroglia.AsyncApi.Core/v2/SecuritySchemeDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2SecuritySchemeDefinition.cs similarity index 98% rename from src/Neuroglia.AsyncApi.Core/v2/SecuritySchemeDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2SecuritySchemeDefinition.cs index 67c2f40..05f6304 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/SecuritySchemeDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2SecuritySchemeDefinition.cs @@ -17,7 +17,7 @@ namespace Neuroglia.AsyncApi.v2; /// Represents an object used to define a security scheme /// [DataContract] -public record SecuritySchemeDefinition +public record V2SecuritySchemeDefinition : ReferenceableComponentDefinition { diff --git a/src/Neuroglia.AsyncApi.Core/v2/ServerDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2ServerDefinition.cs similarity index 93% rename from src/Neuroglia.AsyncApi.Core/v2/ServerDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2ServerDefinition.cs index cca08f3..fb0d32b 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/ServerDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2ServerDefinition.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2.Bindings; - namespace Neuroglia.AsyncApi.v2; /// @@ -23,7 +21,7 @@ namespace Neuroglia.AsyncApi.v2; /// Variable substitution can be used so that some details, for example usernames and passwords, can be injected by code generation tools. /// [DataContract] -public record ServerDefinition +public record V2ServerDefinition { /// @@ -58,7 +56,7 @@ public record ServerDefinition /// Gets/sets an optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text representation. /// [DataMember(Order = 5, Name = "variables"), JsonPropertyOrder(5), JsonPropertyName("variables"), YamlMember(Order = 5, Alias = "variables")] - public virtual EquatableDictionary? Variables { get; set; } + public virtual EquatableDictionary? Variables { get; set; } /// /// Gets/sets an of values that represent alternative security requirement objects that can be used. @@ -68,7 +66,7 @@ public record ServerDefinition public virtual EquatableDictionary? Security { get; set; } /// - /// Gets/sets an object used to configure the 's s + /// Gets/sets an object used to configure the 's s /// [DataMember(Order = 7, Name = "bindings"), JsonPropertyOrder(7), JsonPropertyName("bindings"), YamlMember(Order = 7, Alias = "bindings")] public virtual ServerBindingDefinitionCollection? Bindings { get; set; } @@ -92,6 +90,6 @@ public virtual Uri InterpolateUrlVariables() } /// - public override string ToString() => Url.ToString(); + public override string ToString() => this.Url.ToString(); } diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs new file mode 100644 index 0000000..044ae7e --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs @@ -0,0 +1,70 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object that provides metadata about the API. The metadata can be used by the clients if needed +/// +[DataContract] +public record V3ApiInfo +{ + + /// + /// Gets/sets the title of the application + /// + [Required] + [DataMember(Order = 1, Name = "title"), JsonPropertyOrder(1), JsonPropertyName("title"), YamlMember(Order = 1, Alias = "title")] + public virtual string Title { get; set; } = null!; + + /// + /// Gets/sets the version of the application API (not to be confused with the specification version) + /// + [Required] + [DataMember(Order = 2, Name = "version"), JsonPropertyOrder(2), JsonPropertyName("version"), YamlMember(Order = 2, Alias = "version")] + public virtual string Version { get; set; } = null!; + + /// + /// Gets/sets a short description of the application. CommonMark syntax can be used for rich text representation. + /// + [DataMember(Order = 3, Name = "description"), JsonPropertyOrder(3), JsonPropertyName("description"), YamlMember(Order = 3, Alias = "description")] + public virtual string? Description { get; set; } + + /// + /// Gets/sets a to the Terms of Service for the API. + /// + [DataMember(Order = 4, Name = "termsOfService"), JsonPropertyOrder(4), JsonPropertyName("termsOfService"), YamlMember(Order = 4, Alias = "termsOfService")] + public virtual Uri? TermsOfService { get; set; } + + /// + /// Gets/sets the contact information for the exposed API. + /// + [DataMember(Order = 5, Name = "contact"), JsonPropertyOrder(5), JsonPropertyName("contact"), YamlMember(Order = 5, Alias = "contact")] + public virtual ContactDefinition? Contact { get; set; } + + /// + /// Gets/sets the license information for the exposed API. + /// + [DataMember(Order = 6, Name = "license"), JsonPropertyOrder(6), JsonPropertyName("license"), YamlMember(Order = 6, Alias = "license")] + public virtual LicenseDefinition? License { get; set; } + + /// + /// Gets/sets a list of tags for application API documentation control. Tags can be used for logical grouping of applications. + /// + [DataMember(Order = 7, Name = "tags"), JsonPropertyOrder(7), JsonPropertyName("tags"), YamlMember(Order = 7, Alias = "tags")] + public virtual EquatableList? Tags { get; set; } + + /// + public override string ToString() => this.Title; + +} diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs b/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs new file mode 100644 index 0000000..7195a33 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs @@ -0,0 +1,83 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an Async API version 3 document +/// +[DataContract] +public record V3AsyncApiDocument +{ + + /// + /// Gets/sets the the AsyncAPI Specification version being used. It can be used by tooling Specifications and clients to interpret the version. + /// + /// + /// The structure shall be major.minor.patch, where patch versions must be compatible with the existing major.minor tooling. + /// Typically patch versions will be introduced to address errors in the documentation, and tooling should typically be compatible with the corresponding major.minor (1.0.*). + /// Patch versions will correspond to patches of this document. + /// + [Required] + [DataMember(Order = 1, Name = "asyncapi"), JsonPropertyOrder(1), JsonPropertyName("asyncapi"), YamlMember(Order = 1, Alias = "asyncapi", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string AsyncApi { get; set; } = AsyncApiSpecVersion.V3; + + /// + /// Gets/sets the identifier of the application the AsyncAPI document is defining + /// + [DataMember(Order = 2, Name = "id"), JsonPropertyOrder(2), JsonPropertyName("id"), YamlMember(Order = 2, Alias = "id")] + public virtual string? Id { get; set; } + + /// + /// Gets/sets the object that provides metadata about the API. The metadata can be used by the clients if needed. + /// + [Required] + [DataMember(Order = 3, Name = "info"), JsonPropertyOrder(3), JsonPropertyName("info"), YamlMember(Order = 3, Alias = "info")] + public virtual V3ApiInfo Info { get; set; } = null!; + + /// + /// Gets/sets a containing name/configuration mappings for the application's servers + /// + [DataMember(Order = 4, Name = "servers"), JsonPropertyOrder(4), JsonPropertyName("servers"), YamlMember(Order = 4, Alias = "servers")] + public virtual EquatableDictionary? Servers { get; set; } + + /// + /// Gets/sets the default content type to use when encoding/decoding a message's payload. + /// + [DataMember(Order = 5, Name = "defaultContentType"), JsonPropertyOrder(5), JsonPropertyName("defaultContentType"), YamlMember(Order = 5, Alias = "defaultContentType")] + public virtual string? DefaultContentType { get; set; } + + /// + /// Gets/sets a collection containing the available channels and messages for the API. + /// + [Required, MinLength(1)] + [DataMember(Order = 6, Name = "channels"), JsonPropertyOrder(6), JsonPropertyName("channels"), YamlMember(Order = 6, Alias = "channels")] + public virtual EquatableDictionary Channels { get; set; } = null!; + + /// + /// Gets/sets a name/value map of the operations this application MUST implement. + /// + [Required, MinLength(1)] + [DataMember(Order = 6, Name = "channels"), JsonPropertyOrder(6), JsonPropertyName("channels"), YamlMember(Order = 6, Alias = "channels")] + public virtual EquatableDictionary Operations { get; set; } = null!; + + /// + /// Gets/sets an element to hold various reusable objects for the specification. Everything that is defined inside this object represents a resource that MAY or MAY NOT be used in the rest of the document and MAY or MAY NOT be used by the implemented Application. + /// + [DataMember(Order = 7, Name = "components"), JsonPropertyOrder(7), JsonPropertyName("components"), YamlMember(Order = 7, Alias = "components")] + public virtual V3ComponentDefinitionCollection? Components { get; set; } + + /// + public override string? ToString() => this.Info == null || string.IsNullOrWhiteSpace(this.Info.Title) ? Id : this.Info?.Title; + +} diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs new file mode 100644 index 0000000..cdc240a --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs @@ -0,0 +1,90 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object used to describe a shared communication channel. +/// +[DataContract] +public record V3ChannelDefinition + : ReferenceableComponentDefinition +{ + + /// + /// Gets/sets n optional string representation of this channel's address. + /// The address is typically the "topic name", "routing key", "event type", or "path". W + /// hen null or absent, it MUST be interpreted as unknown. This is useful when the address is generated dynamically at runtime or can't be known upfront. + /// It MAY contain Channel Address Expressions. Query parameters and fragments SHALL NOT be used, instead use bindings to define them. + /// + [DataMember(Order = 1, Name = "address"), JsonPropertyOrder(1), JsonPropertyName("address"), YamlMember(Order = 1, Alias = "address", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string? Address { get; set; } + + /// + /// Gets/sets a map of the messages that will be sent to this channel by any application at any time. Every message sent to this channel MUST be valid against one, and only one, of the message objects defined in this map. + /// + [DataMember(Order = 2, Name = "messages"), JsonPropertyOrder(2), JsonPropertyName("messages"), YamlMember(Order = 2, Alias = "messages", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual EquatableDictionary? Messages { get; set; } + + /// + /// Gets/sets a human-friendly title for the channel. + /// + [DataMember(Order = 3, Name = "title"), JsonPropertyOrder(3), JsonPropertyName("title"), YamlMember(Order = 3, Alias = "title", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string? Title { get; set; } + + /// + /// Gets/sets a short summary of the channel. + /// + [DataMember(Order = 4, Name = "summary"), JsonPropertyOrder(4), JsonPropertyName("summary"), YamlMember(Order = 4, Alias = "summary", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string? Summary { get; set; } + + /// + /// Gets/sets an optional description of this channel. CommonMark syntax can be used for rich text representation. + /// + [DataMember(Order = 5, Name = "description"), JsonPropertyOrder(5), JsonPropertyName("description"), YamlMember(Order = 5, Alias = "description", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string? Description { get; set; } + + /// + /// Gets/sets an array of $ref pointers to the definition of the servers in which this channel is available + /// + [DataMember(Order = 6, Name = "servers"), JsonPropertyOrder(6), JsonPropertyName("servers"), YamlMember(Order = 6, Alias = "servers", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual EquatableList Servers { get; set; } = []; + + /// + /// Gets/sets a map of the parameters included in the channel address. It MUST be present only when the address contains Channel Address Expressions. + /// + [DataMember(Order = 7, Name = "parameters"), JsonPropertyOrder(7), JsonPropertyName("parameters"), YamlMember(Order = 7, Alias = "parameters", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual EquatableDictionary? Parameters { get; set; } + + /// + /// Gets/sets a list of tags for logical grouping of channels. + /// + [DataMember(Order = 8, Name = "tags"), JsonPropertyOrder(8), JsonPropertyName("tags"), YamlMember(Order = 8, Alias = "tags", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual EquatableList? Tags { get; set; } + + /// + /// Gets/sets additional external documentation for this channel. + /// + [DataMember(Order = 9, Name = "externalDocs"), JsonPropertyOrder(9), JsonPropertyName("externalDocs"), YamlMember(Order = 9, Alias = "externalDocs", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + + /// + /// Gets/sets additional external documentation for this channel. + /// + [DataMember(Order = 10, Name = "bindings"), JsonPropertyOrder(10), JsonPropertyName("bindings"), YamlMember(Order = 10, Alias = "bindings", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual ChannelBindingDefinitionCollection? Bindings { get; set; } + + /// + public override string ToString() => string.IsNullOrWhiteSpace(this.Address) ? base.ToString() : this.Address; + +} diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ComponentDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ComponentDefinitionCollection.cs new file mode 100644 index 0000000..732f8bb --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ComponentDefinitionCollection.cs @@ -0,0 +1,138 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object that holds a set of reusable objects for different aspects of the AsyncAPI specification. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. +/// +[DataContract] +public record V3ComponentDefinitionCollection +{ + + /// + /// Gets/sets a key/value mapping that contains reusable Schema Objects. + /// If this is a Schema Object, then the schemaFormat will be assumed to be "application/vnd.aai.asyncapi+json;version=asyncapi" where the version is equal to the AsyncAPI Version String. + /// + [DataMember(Order = 1, Name = "schemas"), JsonPropertyOrder(1), JsonPropertyName("schemas"), YamlMember(Order = 1, Alias = "schemas")] + public virtual EquatableDictionary? Schemas { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Server Objects. + /// + [DataMember(Order = 2, Name = "servers"), JsonPropertyOrder(2), JsonPropertyName("servers"), YamlMember(Order = 2, Alias = "servers")] + public virtual EquatableDictionary? Servers { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Channel Objects. + /// + [DataMember(Order = 3, Name = "channels"), JsonPropertyOrder(3), JsonPropertyName("channels"), YamlMember(Order = 3, Alias = "channels")] + public virtual EquatableDictionary? Channels { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Operation Objects. + /// + [DataMember(Order = 4, Name = "operations"), JsonPropertyOrder(4), JsonPropertyName("operations"), YamlMember(Order = 4, Alias = "operations")] + public virtual EquatableDictionary? Operations { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Message Objects. + /// + [DataMember(Order = 5, Name = "messages"), JsonPropertyOrder(5), JsonPropertyName("messages"), YamlMember(Order = 5, Alias = "messages")] + public virtual EquatableDictionary? Messages { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Security Scheme Objects. + /// + [DataMember(Order = 6, Name = "securitySchemes"), JsonPropertyOrder(6), JsonPropertyName("securitySchemes"), YamlMember(Order = 6, Alias = "securitySchemes")] + public virtual EquatableDictionary? SecuritySchemes { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Server Variable Objects. + /// + [DataMember(Order = 7, Name = "serverVariables"), JsonPropertyOrder(7), JsonPropertyName("serverVariables"), YamlMember(Order = 7, Alias = "serverVariables")] + public virtual EquatableDictionary? ServerVariables { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Parameter Objects. + /// + [DataMember(Order = 8, Name = "parameters"), JsonPropertyOrder(8), JsonPropertyName("parameters"), YamlMember(Order = 8, Alias = "parameters")] + public virtual EquatableDictionary? Parameters { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Correlation Id Objects. + /// + [DataMember(Order = 9, Name = "correlationIds"), JsonPropertyOrder(9), JsonPropertyName("correlationIds"), YamlMember(Order = 9, Alias = "correlationIds")] + public virtual EquatableDictionary? CorrelationIds { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Reply Objects. + /// + [DataMember(Order = 10, Name = "replies"), JsonPropertyOrder(10), JsonPropertyName("replies"), YamlMember(Order = 10, Alias = "replies")] + public virtual EquatableDictionary? Replies { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Reply Address Objects. + /// + [DataMember(Order = 11, Name = "replyAddresses"), JsonPropertyOrder(11), JsonPropertyName("replyAddresses"), YamlMember(Order = 11, Alias = "replyAddresses")] + public virtual EquatableDictionary? ReplyAddresses { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable External Documentation Objects. + /// + [DataMember(Order = 12, Name = "externalDocs"), JsonPropertyOrder(12), JsonPropertyName("externalDocs"), YamlMember(Order = 12, Alias = "externalDocs")] + public virtual EquatableDictionary? ExternalDocs { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Tag Objects. + /// + [DataMember(Order = 13, Name = "tags"), JsonPropertyOrder(13), JsonPropertyName("tags"), YamlMember(Order = 13, Alias = "tags")] + public virtual EquatableDictionary? Tags { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Operation Trait Objects. + /// + [DataMember(Order = 14, Name = "operationTraits"), JsonPropertyOrder(14), JsonPropertyName("operationTraits"), YamlMember(Order = 14, Alias = "operationTraits")] + public virtual EquatableDictionary? OperationTraits { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Message Trait Objects. + /// + [DataMember(Order = 15, Name = "messageTraits"), JsonPropertyOrder(15), JsonPropertyName("messageTraits"), YamlMember(Order = 15, Alias = "messageTraits")] + public virtual EquatableDictionary? MessageTraits { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Server Binding Objects. + /// + [DataMember(Order = 16, Name = "serverBindings"), JsonPropertyOrder(16), JsonPropertyName("serverBindings"), YamlMember(Order = 16, Alias = "serverBindings")] + public virtual EquatableDictionary? ServerBindings { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Channel Binding Objects. + /// + [DataMember(Order = 17, Name = "channelBindings"), JsonPropertyOrder(17), JsonPropertyName("channelBindings"), YamlMember(Order = 17, Alias = "channelBindings")] + public virtual EquatableDictionary? ChannelBindings { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Operation Binding Objects. + /// + [DataMember(Order = 18, Name = "operationBindings"), JsonPropertyOrder(18), JsonPropertyName("operationBindings"), YamlMember(Order = 18, Alias = "operationBindings")] + public virtual EquatableDictionary? OperationBindings { get; set; } + + /// + /// Gets/sets a key/value mapping that contains reusable Message Binding Objects. + /// + [DataMember(Order = 19, Name = "messageBindings"), JsonPropertyOrder(19), JsonPropertyName("messageBindings"), YamlMember(Order = 19, Alias = "messageBindings")] + public virtual EquatableDictionary? MessageBindings { get; set; } + +} diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3MessageDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3MessageDefinition.cs new file mode 100644 index 0000000..ebaf411 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3MessageDefinition.cs @@ -0,0 +1,37 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object that +/// +[DataContract] +public record V3MessageDefinition + : V3MessageTraitDefinition +{ + + /// + /// Gets/sets the definition of the message payload. + /// If this is a Schema Object, then the schemaFormat will be assumed to be "application/vnd.aai.asyncapi+json;version=asyncapi" where the version is equal to the AsyncAPI Version String. + /// + [DataMember(Order = 1, Name = "payload"), JsonPropertyOrder(1), JsonPropertyName("payload"), YamlMember(Order = 1, Alias = "payload")] + public virtual V3SchemaDefinition? Payload { get; set; } + + /// + /// Gets/sets a list of traits to apply to the message object. Traits MUST be merged using traits merge mechanism. The resulting object MUST be a valid Message Object. + /// + [DataMember(Order = 2, Name = "traits"), JsonPropertyOrder(2), JsonPropertyName("traits"), YamlMember(Order = 2, Alias = "traits")] + public virtual EquatableList? Traits { get; set; } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3MessageExampleDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3MessageExampleDefinition.cs new file mode 100644 index 0000000..0dced6b --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3MessageExampleDefinition.cs @@ -0,0 +1,47 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an example of a Message Object. +/// +[DataContract] +public record V3MessageExampleDefinition +{ + + /// + /// Gets/sets the message's headers. MUST validate against the Message Object's headers field. + /// + [DataMember(Order = 1, Name = "headers"), JsonPropertyOrder(1), JsonPropertyName("headers"), YamlMember(Order = 1, Alias = "headers")] + public virtual EquatableDictionary? Headers { get; set; } + + /// + /// Gets/sets the message's payload. MUST validate against the Message Object's payload field. + /// + [DataMember(Order = 2, Name = "payload"), JsonPropertyOrder(2), JsonPropertyName("payload"), YamlMember(Order = 2, Alias = "payload")] + public virtual EquatableDictionary? Payload { get; set; } + + /// + /// Gets/sets a machine-friendly name. + /// + [DataMember(Order = 3, Name = "name"), JsonPropertyOrder(3), JsonPropertyName("name"), YamlMember(Order = 3, Alias = "name")] + public virtual string? Name { get; set; } + + /// + /// Gets/sets a short summary of what the example is about. + /// + [DataMember(Order = 4, Name = "summary"), JsonPropertyOrder(4), JsonPropertyName("summary"), YamlMember(Order = 4, Alias = "summary")] + public virtual string? Summary { get; set; } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3MessageTraitDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3MessageTraitDefinition.cs new file mode 100644 index 0000000..7b68a8f --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3MessageTraitDefinition.cs @@ -0,0 +1,95 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object that describes a trait that MAY be applied to a Message Object. +/// +[DataContract] +public record V3MessageTraitDefinition + : ReferenceableComponentDefinition +{ + + /// + /// Gets/sets the schema definition of the application headers. + /// Schema MUST be a map of key-value pairs. + /// It MUST NOT define the protocol headers. + /// If this is a Schema Object, then the schemaFormat will be assumed to be "application/vnd.aai.asyncapi+json;version=asyncapi" where the version is equal to the AsyncAPI Version String. + /// + [DataMember(Order = 1, Name = "headers"), JsonPropertyOrder(1), JsonPropertyName("headers"), YamlMember(Order = 1, Alias = "headers")] + public virtual V3SchemaDefinition? Headers { get; set; } + + /// + /// Gets/sets the definition of the correlation ID used for message tracing or matching. + /// + [DataMember(Order = 2, Name = "correlationId"), JsonPropertyOrder(2), JsonPropertyName("correlationId"), YamlMember(Order = 2, Alias = "correlationId")] + public virtual CorrelationIdDefinition? CorrelationId { get; set; } + + /// + /// Gets/sets the content type to use when encoding/decoding a message's payload. + /// The value MUST be a specific media type (e.g. application/json). + /// When omitted, the value MUST be the one specified on the defaultContentType field. + /// + [DataMember(Order = 3, Name = "contentType"), JsonPropertyOrder(3), JsonPropertyName("contentType"), YamlMember(Order = 3, Alias = "contentType")] + public virtual string? ContentType { get; set; } + + /// + /// Gets/sets a machine-friendly name for the message. + /// + [DataMember(Order = 4, Name = "name"), JsonPropertyOrder(4), JsonPropertyName("name"), YamlMember(Order = 4, Alias = "name")] + public virtual string? Name { get; set; } + + /// + /// Gets/sets a human-friendly name for the message. + /// + [DataMember(Order = 5, Name = "title"), JsonPropertyOrder(5), JsonPropertyName("title"), YamlMember(Order = 5, Alias = "title")] + public virtual string? Title { get; set; } + + /// + /// Gets/sets a short summary of what the message is about. + /// + [DataMember(Order = 6, Name = "summary"), JsonPropertyOrder(6), JsonPropertyName("summary"), YamlMember(Order = 6, Alias = "summary")] + public virtual string? Summary { get; set; } + + /// + /// Gets/sets a verbose explanation of the message. CommonMark syntax can be used for rich text representation. + /// + [DataMember(Order = 7, Name = "description"), JsonPropertyOrder(7), JsonPropertyName("description"), YamlMember(Order = 7, Alias = "description")] + public virtual string? Description { get; set; } + + /// + /// Gets/sets a list of tags for logical grouping and categorization of messages. + /// + [DataMember(Order = 8, Name = "tags"), JsonPropertyOrder(8), JsonPropertyName("tags"), YamlMember(Order = 8, Alias = "tags")] + public virtual EquatableList? Tags { get; set; } + + /// + /// Gets/sets additional external documentation for this message. + /// + [DataMember(Order = 9, Name = "externalDocs"), JsonPropertyOrder(9), JsonPropertyName("externalDocs"), YamlMember(Order = 9, Alias = "externalDocs")] + public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + + /// + /// Gets/sets a map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the message. + /// + [DataMember(Order = 10, Name = "bindings"), JsonPropertyOrder(10), JsonPropertyName("bindings"), YamlMember(Order = 10, Alias = "bindings")] + public virtual MessageBindingDefinitionCollection? Bindings { get; set; } + + /// + /// Gets/sets a list of examples. + /// + [DataMember(Order = 11, Name = "examples"), JsonPropertyOrder(11), JsonPropertyName("examples"), YamlMember(Order = 11, Alias = "examples")] + public virtual EquatableList? Examples { get; set; } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3OperationAction.cs b/src/Neuroglia.AsyncApi.Core/v3/V3OperationAction.cs new file mode 100644 index 0000000..67b35b4 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3OperationAction.cs @@ -0,0 +1,33 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Enumerates all Async API operation actions +/// +[JsonConverter(typeof(StringEnumConverter))] +[TypeConverter(typeof(EnumMemberTypeConverter))] +public enum V3OperationAction +{ + /// + /// Indicates that the application will send a message to the given channel + /// + [EnumMember(Value = "send")] + Send = 1, + /// + /// Indicates that the application should expect receiving messages from the given channel + /// + [EnumMember(Value = "receive")] + Receive = 2 +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3OperationDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3OperationDefinition.cs new file mode 100644 index 0000000..0253f49 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3OperationDefinition.cs @@ -0,0 +1,56 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object that describes a specific operation. +/// +[DataContract] +public record V3OperationDefinition + : V3OperationTraitDefinition +{ + + /// + /// Gets/sets the operation's action + /// + [Required] + [DataMember(Order = 1, Name = "action"), JsonPropertyOrder(1), JsonPropertyName("action"), YamlMember(Order = 1, Alias = "action", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual V3OperationAction Action { get; set; } + + /// + /// Gets/sets a $ref pointer to the definition of the channel in which this operation is performed. + /// + [Required] + [DataMember(Order = 2, Name = "channel"), JsonPropertyOrder(2), JsonPropertyName("channel"), YamlMember(Order = 2, Alias = "channel", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual V3ReferenceDefinition Channel { get; set; } = null!; + + /// + /// Gets/sets a list of traits to apply to the operation object. Traits MUST be merged using traits merge mechanism. The resulting object MUST be a valid Operation Object. + /// + [DataMember(Order = 3, Name = "traits"), JsonPropertyOrder(3), JsonPropertyName("traits"), YamlMember(Order = 3, Alias = "traits", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual EquatableList? Traits { get; set; } + + /// + /// Gets/sets a list of $ref pointers pointing to the supported Message Objects that can be processed by this operation. + /// + [DataMember(Order = 4, Name = "messages"), JsonPropertyOrder(4), JsonPropertyName("messages"), YamlMember(Order = 4, Alias = "messages", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual EquatableList? Messages { get; set; } + + /// + /// Gets/sets the definition of the reply in a request-reply operation. + /// + [DataMember(Order = 5, Name = "reply"), JsonPropertyOrder(5), JsonPropertyName("reply"), YamlMember(Order = 5, Alias = "reply", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual V3OperationReplyDefinition? Reply { get; set; } + +} diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3OperationReplyAddressDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3OperationReplyAddressDefinition.cs new file mode 100644 index 0000000..b56ca37 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3OperationReplyAddressDefinition.cs @@ -0,0 +1,36 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object that specifies where an operation has to send the reply. +/// +[DataContract] +public record V3OperationReplyAddressDefinition + : ReferenceableComponentDefinition +{ + + /// + /// Gets/sets an optional description of the address. CommonMark syntax can be used for rich text representation. + /// + [DataMember(Order = 1, Name = "description"), JsonPropertyOrder(1), JsonPropertyName("description"), YamlMember(Order = 1, Alias = "description", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string? Description { get; set; } + + /// + /// Gets/sets a runtime expression that specifies the location of the reply address. + /// + [DataMember(Order = 2, Name = "location"), JsonPropertyOrder(2), JsonPropertyName("location"), YamlMember(Order = 2, Alias = "location", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string Location { get; set; } = null!; + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3OperationReplyDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3OperationReplyDefinition.cs new file mode 100644 index 0000000..f4138c4 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3OperationReplyDefinition.cs @@ -0,0 +1,42 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object that describes the reply part that MAY be applied to an Operation Object. If an operation implements the request/reply pattern, the reply object represents the response message. +/// +[DataContract] +public record V3OperationReplyDefinition + : ReferenceableComponentDefinition +{ + + /// + /// Gets/sets the definition of the address that implementations MUST use for the reply. + /// + [DataMember(Order = 1, Name = "address"), JsonPropertyOrder(1), JsonPropertyName("address"), YamlMember(Order = 1, Alias = "address", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual V3OperationReplyAddressDefinition? Address { get; set; } + + /// + /// Gets/sets a $ref pointer to the definition of the channel in which this operation is performed. When address is specified, the address property of the channel referenced by this property MUST be either null or not defined. + /// + [DataMember(Order = 2, Name = "channel"), JsonPropertyOrder(2), JsonPropertyName("channel"), YamlMember(Order = 2, Alias = "channel", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual V3ReferenceDefinition? Channel { get; set; } + + /// + /// Gets/sets a list of $ref pointers pointing to the supported Message Objects that can be processed by this operation as reply. + /// + [DataMember(Order = 3, Name = "messages"), JsonPropertyOrder(3), JsonPropertyName("messages"), YamlMember(Order = 3, Alias = "messages", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual EquatableList? Messages { get; set; } + +} diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3OperationTraitDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3OperationTraitDefinition.cs new file mode 100644 index 0000000..6afa176 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3OperationTraitDefinition.cs @@ -0,0 +1,66 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object that describes a trait that MAY be applied to an Operation Object. +/// +[DataContract] +public record V3OperationTraitDefinition + : ReferenceableComponentDefinition +{ + + /// + /// Gets/sets a human-friendly title for the operation. + /// + [DataMember(Order = 1, Name = "title"), JsonPropertyOrder(1), JsonPropertyName("title"), YamlMember(Order = 1, Alias = "title", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string? Title { get; set; } + + /// + /// Gets/sets a short summary of what the operation is about. + /// + [DataMember(Order = 2, Name = "summary"), JsonPropertyOrder(2), JsonPropertyName("summary"), YamlMember(Order = 2, Alias = "summary", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string? Summary { get; set; } + + /// + /// Gets/sets a verbose explanation of the operation. CommonMark syntax can be used for rich text representation. + /// + [DataMember(Order = 3, Name = "description"), JsonPropertyOrder(3), JsonPropertyName("description"), YamlMember(Order = 3, Alias = "description", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string? Description { get; set; } + + /// + /// Gets/sets a declaration of which security schemes are associated with this operation. Only one of the security scheme objects MUST be satisfied to authorize an operation. In cases where Server Security also applies, it MUST also be satisfied. + /// + [DataMember(Order = 4, Name = "security"), JsonPropertyOrder(4), JsonPropertyName("security"), YamlMember(Order = 4, Alias = "security", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual EquatableList? Security { get; set; } + + /// + /// Gets/sets a list of tags for logical grouping and categorization of operations. + /// + [DataMember(Order = 5, Name = "tags"), JsonPropertyOrder(5), JsonPropertyName("tags"), YamlMember(Order = 5, Alias = "tags", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual EquatableList? Tags { get; set; } + + /// + /// Gets/sets additional external documentation for this operation. + /// + [DataMember(Order = 6, Name = "externalDocs"), JsonPropertyOrder(6), JsonPropertyName("externalDocs"), YamlMember(Order = 6, Alias = "externalDocs", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + + /// + /// Gets/sets a map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the operation. + /// + [DataMember(Order = 7, Name = "bindings"), JsonPropertyOrder(7), JsonPropertyName("bindings"), YamlMember(Order = 7, Alias = "bindings", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual OperationBindingDefinitionCollection? Bindings { get; set; } + +} diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ParameterDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ParameterDefinition.cs new file mode 100644 index 0000000..06947c0 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ParameterDefinition.cs @@ -0,0 +1,54 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object used to describe a parameter included in a channel address. +/// +[DataContract] +public record V3ParameterDefinition + : ReferenceableComponentDefinition +{ + + /// + /// Gets/sets an enumeration of string values to be used if the substitution options are from a limited set. + /// + [DataMember(Order = 1, Name = "enum"), JsonPropertyOrder(1), JsonPropertyName("enum"), YamlMember(Order = 1, Alias = "enum", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual EquatableList? Enum { get; set; } + + /// + /// Gets/sets the default value to use for substitution, and to send, if an alternate value is not supplied. + /// + [DataMember(Order = 2, Name = "default"), JsonPropertyOrder(2), JsonPropertyName("default"), YamlMember(Order = 2, Alias = "default", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string? Default { get; set; } + + /// + /// Gets/sets an optional description for the parameter. CommonMark syntax MAY be used for rich text representation. + /// + [DataMember(Order = 3, Name = "description"), JsonPropertyOrder(3), JsonPropertyName("description"), YamlMember(Order = 3, Alias = "description", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string? Description { get; set; } + + /// + /// Gets/sets an array of examples of the parameter value. + /// + [DataMember(Order = 4, Name = "examples"), JsonPropertyOrder(4), JsonPropertyName("examples"), YamlMember(Order = 4, Alias = "examples", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual EquatableList? Examples { get; set; } + + /// + /// Gets/sets a runtime expression that specifies the location of the parameter value. + /// + [DataMember(Order = 5, Name = "location"), JsonPropertyOrder(5), JsonPropertyName("location"), YamlMember(Order = 5, Alias = "location", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string? Location { get; set; } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ReferenceDefinition.cs similarity index 60% rename from src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsBindingDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v3/V3ReferenceDefinition.cs index 05d9ace..9a02bbd 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Bindings/Sqs/SqsBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ReferenceDefinition.cs @@ -11,24 +11,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.v2.Bindings.Sqs; +namespace Neuroglia.AsyncApi.v3; /// -/// Represents the base record for all SQS implementations of the interface +/// Represents a reference to a component /// [DataContract] -public abstract record SqsBindingDefinition - : IBindingDefinition +public record V3ReferenceDefinition { - /// - [IgnoreDataMember, JsonIgnore, YamlIgnore] - public IEnumerable Protocols - { - get - { - yield return AsyncApiProtocol.Sqs; - } - } + /// + /// Gets/sets the reference string + /// + [Required] + [DataMember(Order = 1, Name = "$ref"), JsonPropertyOrder(1), JsonPropertyName("$ref"), YamlMember(Order = 1, Alias = "$ref", ScalarStyle = ScalarStyle.SingleQuoted)] + public virtual string Reference { get; set; } = null!; } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3SchemaDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3SchemaDefinition.cs new file mode 100644 index 0000000..a28624d --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3SchemaDefinition.cs @@ -0,0 +1,40 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object that represents a schema definition +/// +[DataContract] +public record V3SchemaDefinition + : ReferenceableComponentDefinition +{ + + /// + /// Gets/sets the string containing the name of the schema format that is used to define the information. + /// If schemaFormat is missing, it MUST default to application/vnd.aai.asyncapi+json;version={{asyncapi}} where {{asyncapi}} matches the AsyncAPI Version String. In such a case, this would make the Multi Format Schema Object equivalent to the Schema Object. When using Reference Object within the schema, the schemaFormat of the resource being referenced MUST match the schemaFormat of the schema that contains the initial reference. + /// + [DataMember(Order = 1, Name = "schemaFormat"), JsonPropertyOrder(1), JsonPropertyName("schemaFormat"), YamlMember(Order = 1, Alias = "schemaFormat")] + public virtual string? SchemaFormat { get; set; } + + /// + /// Gets/sets the definition of the message payload. + /// It can be of any type but defaults to Schema Object. + /// It MUST match the schema format defined in schemaFormat, including the encoding type. + /// + [Required] + [DataMember(Order = 2, Name = "schema"), JsonPropertyOrder(2), JsonPropertyName("schema"), YamlMember(Order = 2, Alias = "schema")] + public virtual object Schema { get; set; } = null!; + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3SecuritySchemeDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3SecuritySchemeDefinition.cs new file mode 100644 index 0000000..94d3861 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3SecuritySchemeDefinition.cs @@ -0,0 +1,82 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object used to define a security scheme +/// +[DataContract] +public record V3SecuritySchemeDefinition + : ReferenceableComponentDefinition +{ + + /// + /// Gets/sets the security scheme's type + /// + [DataMember(Order = 1, Name = "type"), JsonPropertyOrder(1), JsonPropertyName("type"), YamlMember(Order = 1, Alias = "type")] + public virtual SecuritySchemeType Type { get; set; } + + /// + /// Gets/sets the name of the header, query or cookie parameter to be used. + /// + [DataMember(Order = 2, Name = "name"), JsonPropertyOrder(2), JsonPropertyName("name"), YamlMember(Order = 2, Alias = "name")] + public virtual string? Name { get; set; } + + /// + /// Gets/sets a short description of the security scheme. CommonMark syntax can be used for rich text representation. + /// + [DataMember(Order = 3, Name = "description"), JsonPropertyOrder(3), JsonPropertyName("description"), YamlMember(Order = 3, Alias = "description")] + public virtual string? Description { get; set; } + + /// + /// Gets/sets the location of the API key. Valid values are "user" and "password" for and "query", "header" or "cookie" for . + /// + [DataMember(Order = 4, Name = "in"), JsonPropertyOrder(4), JsonPropertyName("in"), YamlMember(Order = 4, Alias = "in")] + public virtual string? In { get; set; } + + /// + /// Gets/sets the name of the HTTP Authorization scheme to be used in the Authorization header as defined in RFC7235. + /// + [DataMember(Order = 5, Name = "scheme"), JsonPropertyOrder(5), JsonPropertyName("scheme"), YamlMember(Order = 5, Alias = "scheme")] + public virtual string? Scheme { get; set; } + + /// + /// Gets/sets an object hint to the client to identify how the bearer token is formatted. + /// Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes. + /// + [DataMember(Order = 6, Name = "bearerFormat"), JsonPropertyOrder(6), JsonPropertyName("bearerFormat"), YamlMember(Order = 6, Alias = "bearerFormat")] + public virtual string? BearerFormat { get; set; } + + /// + /// Gets/sets an object containing configuration information for the flow types supported. + /// + [DataMember(Order = 7, Name = "flows"), JsonPropertyOrder(7), JsonPropertyName("flows"), YamlMember(Order = 7, Alias = "flows")] + public virtual OAuthFlowDefinitionCollection? Flows { get; set; } + + /// + /// Gets/sets the OpenId Connect to discover OAuth2 configuration values. + /// + [DataMember(Order = 8, Name = "openIdConnectUrl"), JsonPropertyOrder(8), JsonPropertyName("openIdConnectUrl"), YamlMember(Order = 8, Alias = "openIdConnectUrl")] + public virtual Uri? OpenIdConnectUrl { get; set; } + + /// + /// Gets/sets a list of the needed scope names. An empty array means no scopes are needed. + /// + [DataMember(Order = 9, Name = "scopes"), JsonPropertyOrder(9), JsonPropertyName("scopes"), YamlMember(Order = 9, Alias = "scopes")] + public virtual EquatableList? Scopes { get; set; } + + /// + public override string ToString() => EnumHelper.Stringify(Type); + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ServerDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ServerDefinition.cs new file mode 100644 index 0000000..f8738c1 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ServerDefinition.cs @@ -0,0 +1,101 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object used to describe a message broker, a server or any other kind of computer program capable of sending and/or receiving data +/// +[DataContract] +public record V3ServerDefinition + : ReferenceableComponentDefinition +{ + + /// + /// Gets/sets the server host name. It MAY include the port. This field supports Server Variables. Variable substitutions will be made when a variable is named in {braces}. + /// + [Required] + [DataMember(Order = 1, Name = "host"), JsonPropertyOrder(1), JsonPropertyName("host"), YamlMember(Order = 1, Alias = "host")] + public virtual string Host { get; set; } = null!; + + /// + /// Gets/sets the protocol this server supports for connection. + /// + [Required] + [DataMember(Order = 2, Name = "protocol"), JsonPropertyOrder(2), JsonPropertyName("protocol"), YamlMember(Order = 2, Alias = "protocol")] + public virtual string Protocol { get; set; } = null!; + + /// + /// Gets/sets the version of the protocol used for connection. For instance: AMQP 0.9.1, HTTP 2.0, Kafka 1.0.0, etc. + /// + [DataMember(Order = 3, Name = "protocolVersion"), JsonPropertyOrder(3), JsonPropertyName("protocolVersion"), YamlMember(Order = 3, Alias = "protocolVersion")] + public virtual string? ProtocolVersion { get; set; } + + /// + /// Gets/sets the path to a resource in the host. This field supports Server Variables. Variable substitutions will be made when a variable is named in {braces}. + /// + [DataMember(Order = 4, Name = "pathname"), JsonPropertyOrder(4), JsonPropertyName("pathname"), YamlMember(Order = 4, Alias = "pathname")] + public virtual string? PathName { get; set; } + + /// + /// Gets/sets an optional string describing the server. CommonMark syntax MAY be used for rich text representation. + /// + [DataMember(Order = 5, Name = "description"), JsonPropertyOrder(5), JsonPropertyName("description"), YamlMember(Order = 5, Alias = "description")] + public virtual string? Description { get; set; } + + /// + /// Gets/sets a human-friendly title for the server. + /// + [DataMember(Order = 6, Name = "title"), JsonPropertyOrder(6), JsonPropertyName("title"), YamlMember(Order = 6, Alias = "title")] + public virtual string? Title { get; set; } + + /// + /// Gets/sets a short summary of the server.short summary of the server. + /// + [DataMember(Order = 7, Name = "summary"), JsonPropertyOrder(7), JsonPropertyName("summary"), YamlMember(Order = 7, Alias = "summary")] + public virtual string? Summary { get; set; } + + /// + /// Gets/sets a map between a variable name and its value. The value is used for substitution in the server's host and pathname template. + /// + [DataMember(Order = 8, Name = "variables"), JsonPropertyOrder(8), JsonPropertyName("variables"), YamlMember(Order = 8, Alias = "variables")] + public virtual EquatableDictionary? Variables { get; set; } + + /// + /// Gets/sets a declaration of which security schemes can be used with this server. The list of values includes alternative security scheme objects that can be used. Only one of the security scheme objects need to be satisfied to authorize a connection or operation. + /// + [DataMember(Order = 9, Name = "security"), JsonPropertyOrder(9), JsonPropertyName("security"), YamlMember(Order = 9, Alias = "security")] + public virtual EquatableList? Security { get; set; } + + /// + /// Gets/sets a list of tags for logical grouping and categorization of servers. + /// + [DataMember(Order = 10, Name = "tags"), JsonPropertyOrder(10), JsonPropertyName("tags"), YamlMember(Order = 10, Alias = "tags")] + public virtual EquatableList? Tags { get; set; } + + /// + /// Gets/sets additional external documentation for this server. + /// + [DataMember(Order = 11, Name = "externalDocs"), JsonPropertyOrder(11), JsonPropertyName("externalDocs"), YamlMember(Order = 11, Alias = "externalDocs")] + public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + + /// + /// Gets/sets a map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the server. + /// + [DataMember(Order = 12, Name = "bindings"), JsonPropertyOrder(12), JsonPropertyName("bindings"), YamlMember(Order = 12, Alias = "bindings")] + public virtual ServerBindingDefinitionCollection? Bindings { get; set; } + + /// + public override string ToString() => this.Host; + +} diff --git a/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/IServiceCollectionExtensions.cs b/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/IServiceCollectionExtensions.cs index 1bdca55..d99f582 100644 --- a/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/IServiceCollectionExtensions.cs +++ b/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/IServiceCollectionExtensions.cs @@ -73,12 +73,12 @@ public static IServiceCollection AddAsyncApiGeneration(this IServiceCollection s } /// - /// Adds and configures a new + /// Adds and configures a new /// /// The to configure - /// The to add + /// The to add /// The configured - public static IServiceCollection AddAsyncApiDocument(this IServiceCollection services, AsyncApiDocument document) + public static IServiceCollection AddAsyncApiDocument(this IServiceCollection services, V2AsyncApiDocument document) { services.AddSingleton(document); @@ -86,10 +86,10 @@ public static IServiceCollection AddAsyncApiDocument(this IServiceCollection ser } /// - /// Adds and configures a new + /// Adds and configures a new /// /// The to configure - /// An used to setup the used to build the to add + /// An used to setup the used to build the to add /// The configured public static IServiceCollection AddAsyncApiDocument(this IServiceCollection services, Action setup) { @@ -104,10 +104,10 @@ public static IServiceCollection AddAsyncApiDocument(this IServiceCollection ser } /// - /// Adds and configures a new + /// Adds and configures a new /// /// The to configure - /// An used to setup the used to build the to add + /// An used to setup the used to build the to add /// The configured public static IServiceCollection AddAsyncApiDocument(this IServiceCollection services, Action setup) { diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/AsyncApiDocumentBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/AsyncApiDocumentBuilder.cs index a5d7673..fab8387 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/AsyncApiDocumentBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/AsyncApiDocumentBuilder.cs @@ -11,8 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; namespace Neuroglia.AsyncApi.FluentBuilders; @@ -23,8 +22,8 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// Initializes a new /// /// The current -/// The services used to validate s -public class AsyncApiDocumentBuilder(IServiceProvider serviceProvider, IEnumerable> validators) +/// The services used to validate s +public class AsyncApiDocumentBuilder(IServiceProvider serviceProvider, IEnumerable> validators) : IAsyncApiDocumentBuilder { @@ -34,14 +33,14 @@ public class AsyncApiDocumentBuilder(IServiceProvider serviceProvider, IEnumerab protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; /// - /// Gets the services used to validate s + /// Gets the services used to validate s /// - protected virtual IEnumerable> Validators { get; } = validators; + protected virtual IEnumerable> Validators { get; } = validators; /// - /// Gets the to configure + /// Gets the to configure /// - protected virtual AsyncApiDocument Document { get; } = new(); + protected virtual V2AsyncApiDocument Document { get; } = new(); /// public virtual IAsyncApiDocumentBuilder WithSpecVersion(string version) @@ -161,7 +160,7 @@ public virtual IAsyncApiDocumentBuilder WithChannel(string name, Action - public virtual IAsyncApiDocumentBuilder WithSecurityScheme(string name, SecuritySchemeDefinition scheme) + public virtual IAsyncApiDocumentBuilder WithSecurityScheme(string name, V2SecuritySchemeDefinition scheme) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); ArgumentNullException.ThrowIfNull(scheme); @@ -196,7 +195,7 @@ public virtual IAsyncApiDocumentBuilder WithSchemaComponent(string name, JsonSch } /// - public virtual IAsyncApiDocumentBuilder WithMessageComponent(string name, MessageDefinition message) + public virtual IAsyncApiDocumentBuilder WithMessageComponent(string name, V2MessageDefinition message) { if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); ArgumentNullException.ThrowIfNull(message); @@ -217,7 +216,7 @@ public virtual IAsyncApiDocumentBuilder WithMessageComponent(string name, Action } /// - public virtual IAsyncApiDocumentBuilder WithParameterComponent(string name, ParameterDefinition parameter) + public virtual IAsyncApiDocumentBuilder WithParameterComponent(string name, V2ParameterDefinition parameter) { if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); ArgumentNullException.ThrowIfNull(parameter); @@ -250,7 +249,7 @@ public virtual IAsyncApiDocumentBuilder WithCorrelationIdComponent(string name, } /// - public virtual IAsyncApiDocumentBuilder WithOperationTraitComponent(string name, OperationTraitDefinition trait) + public virtual IAsyncApiDocumentBuilder WithOperationTraitComponent(string name, V2OperationTraitDefinition trait) { if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); ArgumentNullException.ThrowIfNull(trait); @@ -271,7 +270,7 @@ public virtual IAsyncApiDocumentBuilder WithOperationTraitComponent(string name, } /// - public virtual IAsyncApiDocumentBuilder WithMessageTraitComponent(string name, MessageTraitDefinition trait) + public virtual IAsyncApiDocumentBuilder WithMessageTraitComponent(string name, V2MessageTraitDefinition trait) { if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); ArgumentNullException.ThrowIfNull(trait); @@ -336,7 +335,7 @@ public virtual IAsyncApiDocumentBuilder WithMessageBindingComponent(string name, } /// - public virtual AsyncApiDocument Build() + public virtual V2AsyncApiDocument Build() { var validationResults = this.Validators.Select(v => v.Validate(this.Document)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/ChannelDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/ChannelDefinitionBuilder.cs index aeb1f13..1791174 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/ChannelDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/ChannelDefinitionBuilder.cs @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.Bindings; using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; namespace Neuroglia.AsyncApi.FluentBuilders; @@ -23,8 +23,8 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// Initializes a new /// /// The current -/// The services used to validate s -public class ChannelDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) +/// The services used to validate s +public class ChannelDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) : IChannelDefinitionBuilder { @@ -34,14 +34,14 @@ public class ChannelDefinitionBuilder(IServiceProvider serviceProvider, IEnumera protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; /// - /// Gets the services used to validate s + /// Gets the services used to validate s /// - protected virtual IEnumerable> Validators { get; } = validators; + protected virtual IEnumerable> Validators { get; } = validators; /// - /// Gets the to build + /// Gets the to build /// - protected virtual ChannelDefinition Channel { get; } = new(); + protected virtual V2ChannelDefinition Channel { get; } = new(); /// public virtual IChannelDefinitionBuilder WithDescription(string? description) @@ -72,17 +72,17 @@ public virtual IChannelDefinitionBuilder WithBinding(IChannelBindingDefinition b } /// - public virtual IChannelDefinitionBuilder WithOperation(OperationType type, Action setup) + public virtual IChannelDefinitionBuilder WithOperation(V2OperationType type, Action setup) { ArgumentNullException.ThrowIfNull(setup); var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); setup(builder); switch (type) { - case OperationType.Publish: + case V2OperationType.Publish: this.Channel.Publish = builder.Build(); break; - case OperationType.Subscribe: + case V2OperationType.Subscribe: this.Channel.Subscribe = builder.Build(); break; default: @@ -92,13 +92,13 @@ public virtual IChannelDefinitionBuilder WithOperation(OperationType type, Actio } /// - public virtual IChannelDefinitionBuilder WithSubscribeOperation(Action setup) => this.WithOperation(OperationType.Subscribe, setup); + public virtual IChannelDefinitionBuilder WithSubscribeOperation(Action setup) => this.WithOperation(V2OperationType.Subscribe, setup); /// - public virtual IChannelDefinitionBuilder WithPublishOperation(Action setup) => this.WithOperation(OperationType.Publish, setup); + public virtual IChannelDefinitionBuilder WithPublishOperation(Action setup) => this.WithOperation(V2OperationType.Publish, setup); /// - public virtual ChannelDefinition Build() + public virtual V2ChannelDefinition Build() { var validationResults = this.Validators.Select(v => v.Validate(this.Channel)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IAsyncApiDocumentBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IAsyncApiDocumentBuilder.cs index 600184d..a6b4819 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IAsyncApiDocumentBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IAsyncApiDocumentBuilder.cs @@ -11,61 +11,60 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// public interface IAsyncApiDocumentBuilder { /// - /// Configures the to use the specified Async Api Specification version + /// Configures the to use the specified Async Api Specification version /// /// The Async Api Specification version to use /// The configured IAsyncApiDocumentBuilder WithSpecVersion(string version); /// - /// Configures the to use the specified id + /// Configures the to use the specified id /// /// The id of the Async Api document to build /// The configured IAsyncApiDocumentBuilder WithId(string id); /// - /// Configures the to use the specified API title + /// Configures the to use the specified API title /// /// The title of the Async Api document to build /// The configured IAsyncApiDocumentBuilder WithTitle(string title); /// - /// Configures the to use the specified API version + /// Configures the to use the specified API version /// /// The version of the Async Api document to build /// The configured IAsyncApiDocumentBuilder WithVersion(string version); /// - /// Configures the to use the specified API description + /// Configures the to use the specified API description /// /// The description of the Async Api document to build /// The configured IAsyncApiDocumentBuilder WithDescription(string? description); /// - /// Configures the to use the specified for the API's terms of service + /// Configures the to use the specified for the API's terms of service /// /// The of the API's terms of service /// The configured IAsyncApiDocumentBuilder WithTermsOfService(Uri uri); /// - /// Configures the to use the specified contact for the API + /// Configures the to use the specified contact for the API /// /// The contact name /// The contact @@ -74,7 +73,7 @@ public interface IAsyncApiDocumentBuilder IAsyncApiDocumentBuilder WithContact(string name, Uri? uri = null, string? email = null); /// - /// Configures the to use the specified license + /// Configures the to use the specified license /// /// The name of the license to use /// The license's @@ -82,21 +81,21 @@ public interface IAsyncApiDocumentBuilder IAsyncApiDocumentBuilder WithLicense(string name, Uri? uri = null); /// - /// Configures the to use the specified license + /// Configures the to use the specified license /// /// The content type to use by default /// The configured IAsyncApiDocumentBuilder WithDefaultContentType(string contentType); /// - /// Marks the to build with the specified tag + /// Marks the to build with the specified tag /// /// An used to setup the tag to use /// The configured IAsyncApiDocumentBuilder WithTag(Action setup); /// - /// Adds the specified external documentation to the to build + /// Adds the specified external documentation to the to build /// /// The to the documentation to add /// The description of the documentation to add @@ -104,34 +103,34 @@ public interface IAsyncApiDocumentBuilder IAsyncApiDocumentBuilder WithExternalDocumentation(Uri uri, string? description = null); /// - /// Adds the specified to the to build + /// Adds the specified to the to build /// - /// The name of the to add - /// An used to setup the to add + /// The name of the to add + /// An used to setup the to add /// The configured IAsyncApiDocumentBuilder WithServer(string name, Action setup); /// - /// Adds the specified to the to build + /// Adds the specified to the to build /// - /// The name of the to add - /// An used to setup the to add + /// The name of the to add + /// An used to setup the to add /// The configured IAsyncApiDocumentBuilder WithChannel(string name, Action setup); /// - /// Adds the specified + /// Adds the specified /// - /// The name of the to add - /// The to add + /// The name of the to add + /// The to add /// The configured - IAsyncApiDocumentBuilder WithSecurityScheme(string name, SecuritySchemeDefinition scheme); + IAsyncApiDocumentBuilder WithSecurityScheme(string name, V2SecuritySchemeDefinition scheme); /// - /// Adds the specified + /// Adds the specified /// - /// The name of the to add - /// An used to setup the to add + /// The name of the to add + /// An used to setup the to add /// The configured IAsyncApiDocumentBuilder WithSecurityScheme(string name, Action setup); @@ -144,34 +143,34 @@ public interface IAsyncApiDocumentBuilder IAsyncApiDocumentBuilder WithSchemaComponent(string name, JsonSchema schema); /// - /// Adds the specified + /// Adds the specified /// - /// The name of the to add - /// The to add + /// The name of the to add + /// The to add /// The configured - IAsyncApiDocumentBuilder WithMessageComponent(string name, MessageDefinition message); + IAsyncApiDocumentBuilder WithMessageComponent(string name, V2MessageDefinition message); /// - /// Adds the specified + /// Adds the specified /// - /// The name of the to add - /// An used to setup the to add + /// The name of the to add + /// An used to setup the to add /// The configured IAsyncApiDocumentBuilder WithMessageComponent(string name, Action setup); /// - /// Adds the specified + /// Adds the specified /// - /// The name of the to add - /// The to add + /// The name of the to add + /// The to add /// The configured - IAsyncApiDocumentBuilder WithParameterComponent(string name, ParameterDefinition parameter); + IAsyncApiDocumentBuilder WithParameterComponent(string name, V2ParameterDefinition parameter); /// - /// Adds the specified + /// Adds the specified /// - /// The name of the to add - /// An used to setup the to add + /// The name of the to add + /// An used to setup the to add /// The configured IAsyncApiDocumentBuilder WithParameterComponent(string name, Action setup); @@ -184,34 +183,34 @@ public interface IAsyncApiDocumentBuilder IAsyncApiDocumentBuilder WithCorrelationIdComponent(string name, CorrelationIdDefinition correlationId); /// - /// Adds the specified + /// Adds the specified /// - /// The name of the to add - /// The to add + /// The name of the to add + /// The to add /// The configured - IAsyncApiDocumentBuilder WithOperationTraitComponent(string name, OperationTraitDefinition trait); + IAsyncApiDocumentBuilder WithOperationTraitComponent(string name, V2OperationTraitDefinition trait); /// - /// Adds the specified + /// Adds the specified /// - /// The name of the to add - /// An used to setup the to add + /// The name of the to add + /// An used to setup the to add /// The configured IAsyncApiDocumentBuilder WithOperationTraitComponent(string name, Action setup); /// - /// Adds the specified + /// Adds the specified /// - /// The name of the to add - /// The to add + /// The name of the to add + /// The to add /// The configured - IAsyncApiDocumentBuilder WithMessageTraitComponent(string name, MessageTraitDefinition trait); + IAsyncApiDocumentBuilder WithMessageTraitComponent(string name, V2MessageTraitDefinition trait); /// - /// Adds the specified + /// Adds the specified /// - /// The name of the to add - /// An used to setup the to add + /// The name of the to add + /// An used to setup the to add /// The configured IAsyncApiDocumentBuilder WithMessageTraitComponent(string name, Action setup); @@ -248,9 +247,9 @@ public interface IAsyncApiDocumentBuilder IAsyncApiDocumentBuilder WithMessageBindingComponent(string name, MessageBindingDefinitionCollection bindings); /// - /// Builds a new + /// Builds a new /// - /// A new - AsyncApiDocument Build(); + /// A new + V2AsyncApiDocument Build(); } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IChannelDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IChannelDefinitionBuilder.cs index 605b6a8..67240d0 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IChannelDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IChannelDefinitionBuilder.cs @@ -11,65 +11,65 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.Bindings; using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// public interface IChannelDefinitionBuilder { /// - /// Configures the to build to use the specified description + /// Configures the to build to use the specified description /// - /// The 's description + /// The 's description /// The configured IChannelDefinitionBuilder WithDescription(string? description); /// - /// Adds a new to the to build + /// Adds a new to the to build /// - /// The name of the to add - /// An used to setup the to add + /// The name of the to add + /// An used to setup the to add /// The configured IChannelDefinitionBuilder WithParameter(string name, Action setup); /// - /// Adds the specified to the to build + /// Adds the specified to the to build /// /// The to add /// The configured IChannelDefinitionBuilder WithBinding(IChannelBindingDefinition binding); /// - /// Defines and configures an operation of the to build + /// Defines and configures an operation of the to build /// - /// The 's type - /// An used to setup the Subscribe + /// The 's type + /// An used to setup the Subscribe /// The configured - IChannelDefinitionBuilder WithOperation(OperationType type, Action setup); + IChannelDefinitionBuilder WithOperation(V2OperationType type, Action setup); /// - /// Defines and configures the Subscribe operation of the to build + /// Defines and configures the Subscribe operation of the to build /// - /// An used to setup the Subscribe + /// An used to setup the Subscribe /// The configured IChannelDefinitionBuilder WithSubscribeOperation(Action setup); /// - /// Defines and configures the Publish operation of the to build + /// Defines and configures the Publish operation of the to build /// - /// An used to setup the Publish + /// An used to setup the Publish /// The configured IChannelDefinitionBuilder WithPublishOperation(Action setup); /// - /// Builds a new + /// Builds a new /// - /// A new - ChannelDefinition Build(); + /// A new + V2ChannelDefinition Build(); } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageDefinitionBuilder.cs index a6247a5..394c55c 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageDefinitionBuilder.cs @@ -14,51 +14,51 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// public interface IMessageDefinitionBuilder - : IMessageTraitDefinitionBuilder + : IMessageTraitDefinitionBuilder { /// - /// Configures the to build to use the specified payload + /// Configures the to build to use the specified payload /// - /// The used to define the 's payload + /// The used to define the 's payload /// The configured IMessageDefinitionBuilder WithPayloadSchema(JsonSchema payloadSchema); /// - /// Configures the to build to use the specified payload + /// Configures the to build to use the specified payload /// - /// The type used to define the 's payload + /// The type used to define the 's payload /// The configured IMessageDefinitionBuilder WithPayloadOfType(); /// - /// Configures the to build to use the specified payload + /// Configures the to build to use the specified payload /// - /// The type used to define the 's payload + /// The type used to define the 's payload /// The configured IMessageDefinitionBuilder WithPayloadOfType(Type payloadType); /// - /// Configures the to build to use the specified + /// Configures the to build to use the specified /// - /// An used to setup the to use + /// An used to setup the to use /// The configured IMessageDefinitionBuilder WithTrait(Action setup); /// - /// Configures the to build to use the specified + /// Configures the to build to use the specified /// - /// An used to setup the to use + /// An used to setup the to use /// The configured - IMessageDefinitionBuilder WithTrait(MessageTraitDefinition trait); + IMessageDefinitionBuilder WithTrait(V2MessageTraitDefinition trait); /// - /// Configures the to build to use the specified + /// Configures the to build to use the specified /// - /// The reference to the to use + /// The reference to the to use /// The configured IMessageDefinitionBuilder WithTraitReference(string reference); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageTraitDefinitionBuilder.cs index efc6460..244cd04 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageTraitDefinitionBuilder.cs @@ -11,42 +11,44 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.Bindings; + namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// /// The type of to return for chaining purposes -/// The type of to build +/// The type of to build public interface IMessageTraitDefinitionBuilder where TBuilder : IMessageTraitDefinitionBuilder - where TTrait : MessageTraitDefinition + where TTrait : V2MessageTraitDefinition { /// - /// Configures the to build to use the specified headers + /// Configures the to build to use the specified headers /// - /// The type used to define the 's headers + /// The type used to define the 's headers /// The configured TBuilder WithHeaders() where THeaders : class; /// - /// Configures the to build to use the specified headers + /// Configures the to build to use the specified headers /// - /// The type used to define the 's headers + /// The type used to define the 's headers /// The configured TBuilder WithHeaders(Type headersType); /// - /// Configures the to build to use the specified headers + /// Configures the to build to use the specified headers /// - /// The used to define the 's headers + /// The used to define the 's headers /// The configured TBuilder WithHeaders(JsonSchema headersSchema); /// - /// Configures the to build to use the specified correlation id + /// Configures the to build to use the specified correlation id /// /// The location of the correlation id to use /// The description of the correlation id to use @@ -54,7 +56,7 @@ TBuilder WithHeaders() TBuilder WithCorrelationId(string location, string? description = null); /// - /// Configures the to build to use the specified correlation id + /// Configures the to build to use the specified correlation id /// /// An used to build the runtime expression referencing the location of the correlation id to use /// The description of the correlation id to use @@ -62,62 +64,62 @@ TBuilder WithHeaders() TBuilder WithCorrelationId(Action locationSetup, string? description = null); /// - /// Configures the to build to use the specified schema format + /// Configures the to build to use the specified schema format /// /// The schema format to use /// The configured TBuilder WithSchemaFormat(string schemaFormat); /// - /// Configures the to build to use the specified content type + /// Configures the to build to use the specified content type /// /// The content type to use /// The configured TBuilder WithContentType(string contentType); /// - /// Configures the to build to use the specified content type + /// Configures the to build to use the specified content type /// /// The name to use /// The configured TBuilder WithName(string name); /// - /// Configures the to build to use the specified title + /// Configures the to build to use the specified title /// /// The title to use /// The configured TBuilder WithTitle(string title); /// - /// Configures the to build to use the specified summary + /// Configures the to build to use the specified summary /// /// The summary to use /// The configured TBuilder WithSummary(string summary); /// - /// Configures the to build to use the specified description + /// Configures the to build to use the specified description /// /// The description to use /// The configured TBuilder WithDescription(string? description); /// - /// Adds the specified to the to build + /// Adds the specified to the to build /// /// The to add /// The configured TBuilder WithBinding(IMessageBindingDefinition binding); /// - /// Marks the to build with the specified tag + /// Marks the to build with the specified tag /// /// An used to setup the tag to use /// The configured TBuilder WithTag(Action setup); /// - /// Adds the specified example to the to build + /// Adds the specified example to the to build /// /// The name of the example to add /// The example to use @@ -125,7 +127,7 @@ TBuilder WithHeaders() TBuilder WithExample(string name, object example); /// - /// Adds the specified external documentation to the to build + /// Adds the specified external documentation to the to build /// /// The to the documentation to add /// The description of the documentation to add @@ -133,18 +135,18 @@ TBuilder WithHeaders() TBuilder WithExternalDocumentation(Uri uri, string? description = null); /// - /// Builds a new + /// Builds a new /// - /// A new + /// A new TTrait Build(); } /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// public interface IMessageTraitBuilder - : IMessageTraitDefinitionBuilder + : IMessageTraitDefinitionBuilder { diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOAuthFlowDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOAuthFlowDefinitionBuilder.cs index 521d78a..6f9b72d 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOAuthFlowDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOAuthFlowDefinitionBuilder.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.FluentBuilders; /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOAuthFlowDefinitionCollectionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOAuthFlowDefinitionCollectionBuilder.cs index 60ebfb6..cb3f006 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOAuthFlowDefinitionCollectionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOAuthFlowDefinitionCollectionBuilder.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.FluentBuilders; /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationDefinitionBuilder.cs index 637918f..094f461 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationDefinitionBuilder.cs @@ -16,30 +16,30 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// public interface IOperationDefinitionBuilder - : IOperationTraitDefinitionBuilder + : IOperationTraitDefinitionBuilder { /// - /// Configures the to build to use the specified + /// Configures the to build to use the specified /// - /// An used to setup the to use + /// An used to setup the to use /// The configured IOperationDefinitionBuilder WithTrait(Action setup); /// - /// Configures the to build to use the specified + /// Configures the to build to use the specified /// - /// An used to setup the to use + /// An used to setup the to use /// The configured IOperationDefinitionBuilder WithMessage(Action setup); /// - /// Configures the to build to use the specified s + /// Configures the to build to use the specified s /// - /// An array containing the used to setup the s to use + /// An array containing the used to setup the s to use /// The configured IOperationDefinitionBuilder WithMessages(params Action[] setups); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationTraitDefinitionBuilder.cs index b1103a3..58f907e 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationTraitDefinitionBuilder.cs @@ -11,51 +11,51 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.Bindings; using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// /// The type of to return for chaining purposes -/// The type of to build +/// The type of to build public interface IOperationTraitDefinitionBuilder where TBuilder : IOperationTraitDefinitionBuilder - where TTrait : OperationTraitDefinition + where TTrait : V2OperationTraitDefinition { /// - /// Configures the to use the specified id + /// Configures the to use the specified id /// /// The id of the Async Api document to build /// The configured TBuilder WithOperationId(string operationId); /// - /// Configures the to use the specified API description + /// Configures the to use the specified API description /// /// The summary of the Async Api document to build /// The configured TBuilder WithSummary(string summary); /// - /// Configures the to use the specified API description + /// Configures the to use the specified API description /// /// The description of the Async Api document to build /// The configured TBuilder WithDescription(string? description); /// - /// Marks the to build with the specified tag + /// Marks the to build with the specified tag /// /// An used to setup the tag to use /// The configured TBuilder WithTag(Action setup); /// - /// Adds the specified external documentation to the to build + /// Adds the specified external documentation to the to build /// /// The to the documentation to add /// The description of the documentation to add @@ -63,25 +63,25 @@ public interface IOperationTraitDefinitionBuilder TBuilder WithExternalDocumentation(Uri uri, string? description = null); /// - /// Adds the specified to the to build + /// Adds the specified to the to build /// /// The to add /// The configured TBuilder WithBinding(IOperationBindingDefinition binding); /// - /// Builds a new + /// Builds a new /// - /// A new + /// A new TTrait Build(); } /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// public interface IOperationTraitBuilder - : IOperationTraitDefinitionBuilder + : IOperationTraitDefinitionBuilder { diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IParameterDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IParameterDefinitionBuilder.cs index cf1ba64..f434021 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IParameterDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IParameterDefinitionBuilder.cs @@ -16,50 +16,50 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Defines the fundamentals of the service used to build s +/// Defines the fundamentals of the service used to build s /// public interface IParameterDefinitionBuilder { /// - /// Configures the type of the to build + /// Configures the type of the to build /// - /// The type of the to build + /// The type of the to build /// The configured IParameterDefinitionBuilder OfType(); /// - /// Configures the type of the to build + /// Configures the type of the to build /// - /// The type of the to build + /// The type of the to build /// The configured IParameterDefinitionBuilder OfType(Type parameterType); /// - /// Configures the of the to build + /// Configures the of the to build /// - /// The of the to build + /// The of the to build /// The configured IParameterDefinitionBuilder WithSchema(JsonSchema schema); /// - /// Configures the to build to use the specified description + /// Configures the to build to use the specified description /// /// The description to use /// The configured IParameterDefinitionBuilder WithDescription(string? description); /// - /// Sets the location of the to build + /// Sets the location of the to build /// /// A runtime expression that specifies the location of the parameter value /// The configured IParameterDefinitionBuilder WithLocation(string location); /// - /// Builds a new + /// Builds a new /// - /// A new - ParameterDefinition Build(); + /// A new + V2ParameterDefinition Build(); } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IRuntimeExpressionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IRuntimeExpressionBuilder.cs index b0b0dca..aa8534d 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IRuntimeExpressionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IRuntimeExpressionBuilder.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.FluentBuilders; /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IRuntimeExpressionFragmentBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IRuntimeExpressionFragmentBuilder.cs index f386d90..f3918dd 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IRuntimeExpressionFragmentBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IRuntimeExpressionFragmentBuilder.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.FluentBuilders; /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ISecuritySchemeDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ISecuritySchemeDefinitionBuilder.cs index 27ba312..604d401 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ISecuritySchemeDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ISecuritySchemeDefinitionBuilder.cs @@ -11,76 +11,74 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// public interface ISecuritySchemeDefinitionBuilder { /// - /// Configures the to build to be of the specified + /// Configures the to build to be of the specified /// - /// The of the to build + /// The of the to build /// The configured ISecuritySchemeDefinitionBuilder WithType(SecuritySchemeType type); /// - /// Configures the to build to use the specified name + /// Configures the to build to use the specified name /// - /// The 's name + /// The 's name /// The configured ISecuritySchemeDefinitionBuilder WithParameterName(string? name); /// - /// Configures the to build to use the specified description + /// Configures the to build to use the specified description /// - /// The 's description + /// The 's description /// The configured ISecuritySchemeDefinitionBuilder WithDescription(string? location); /// - /// Configures the to build to store API keys at the specified location + /// Configures the to build to store API keys at the specified location /// /// The location to store the API key at /// The configured ISecuritySchemeDefinitionBuilder WithApiKeyLocation(string? location); /// - /// Configures the to build to use the specified scheme name in the Authorization header, as defined in RFC7235. + /// Configures the to build to use the specified scheme name in the Authorization header, as defined in RFC7235. /// /// The name of the authorization scheme to use /// The configured ISecuritySchemeDefinitionBuilder WithAuthorizationScheme(string? scheme); /// - /// Configures the to build to use the specified object hint for the client to identify how the bearer token is formatted + /// Configures the to build to use the specified object hint for the client to identify how the bearer token is formatted /// /// The bearer format to use /// The configured ISecuritySchemeDefinitionBuilder WithBearerFormat(string? format); /// - /// Configures the to build to use the specified OpenId Connect to discover OAuth2 configuration values + /// Configures the to build to use the specified OpenId Connect to discover OAuth2 configuration values /// /// The OpenId Connect at which to discover OAuth2 configuration values /// The configured ISecuritySchemeDefinitionBuilder WithOpenIdConnectUrl(Uri? uri); /// - /// Configures the to build to use the specified OAUTH flows + /// Configures the to build to use the specified OAUTH flows /// /// An used to build the s to use /// The configured ISecuritySchemeDefinitionBuilder WithOAuthFlows(Action setup); /// - /// Builds a new + /// Builds a new /// - /// A new - SecuritySchemeDefinition Build(); + /// A new + V2SecuritySchemeDefinition Build(); } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerDefinitionBuilder.cs index 609bc83..33f3aa0 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerDefinitionBuilder.cs @@ -11,26 +11,25 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; +using Neuroglia.AsyncApi.Bindings; namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// public interface IServerDefinitionBuilder { /// - /// Configures the to use the specified url + /// Configures the to use the specified url /// - /// The of the to build + /// The of the to build /// The configured IServerDefinitionBuilder WithUrl(Uri uri); /// - /// Configures the to use the specified protocol + /// Configures the to use the specified protocol /// /// The protocol to use /// The protocol version to use @@ -38,39 +37,39 @@ public interface IServerDefinitionBuilder IServerDefinitionBuilder WithProtocol(string protocol, string? version = null); /// - /// Configures the to use the specified description + /// Configures the to use the specified description /// /// The description to use /// The configured IServerDefinitionBuilder WithDescription(string? description); /// - /// Adds the specified to the to build + /// Adds the specified to the to build /// - /// The name of the to add - /// An used to setup the to add + /// The name of the to add + /// An used to setup the to add /// The configured IServerDefinitionBuilder WithVariable(string name, Action setup); /// - /// Configures the to build to use the specified + /// Configures the to build to use the specified /// - /// The name of the to add + /// The name of the to add /// The security requirement object, if any /// The configured IServerDefinitionBuilder WithSecurityRequirement(string name, object? requirement = null); /// - /// Adds the specified to the to build + /// Adds the specified to the to build /// /// The to add /// The configured IServerDefinitionBuilder WithBinding(IServerBindingDefinition binding); /// - /// Builds a new + /// Builds a new /// - /// A new - ServerDefinition Build(); + /// A new + V2ServerDefinition Build(); } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ITagDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ITagDefinitionBuilder.cs index bc23571..f5f4ac7 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ITagDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ITagDefinitionBuilder.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.FluentBuilders; /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IVariableDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IVariableDefinitionBuilder.cs index 6cac234..a2cf3ce 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IVariableDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IVariableDefinitionBuilder.cs @@ -11,48 +11,46 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// public interface IVariableDefinitionBuilder { /// - /// Configures the to build to use the specified enum values + /// Configures the to build to use the specified enum values /// /// An array of values to be used if the substitution options are from a limited set. /// The configured IVariableDefinitionBuilder WithEnumValues(params string[] values); /// - /// Configures the to build to use the specified default value + /// Configures the to build to use the specified default value /// /// The value to use by default for substitution, and to send, if an alternate value is not supplied. /// The configured IVariableDefinitionBuilder WithDefaultValue(string value); /// - /// Configures the to use the specified description + /// Configures the to use the specified description /// /// The description to use /// The configured IVariableDefinitionBuilder WithDescription(string? description); /// - /// Adds the specified example to the to build + /// Adds the specified example to the to build /// /// The example to add /// The configured IVariableDefinitionBuilder WithExample(string example); /// - /// Builds a new + /// Builds a new /// - /// A new - VariableDefinition Build(); + /// A new + ServerVariableDefinition Build(); } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/MessageDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/MessageDefinitionBuilder.cs index 86b3dfe..f49f099 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/MessageDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/MessageDefinitionBuilder.cs @@ -22,9 +22,9 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// Initializes a new /// /// The current -/// An containing the services used to validate s -public class MessageDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : MessageTraitDefinitionBuilder(serviceProvider, validators), IMessageDefinitionBuilder +/// An containing the services used to validate s +public class MessageDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : MessageTraitDefinitionBuilder(serviceProvider, validators), IMessageDefinitionBuilder { /// @@ -59,7 +59,7 @@ public virtual IMessageDefinitionBuilder WithTrait(Action } /// - public virtual IMessageDefinitionBuilder WithTrait(MessageTraitDefinition trait) + public virtual IMessageDefinitionBuilder WithTrait(V2MessageTraitDefinition trait) { ArgumentNullException.ThrowIfNull(trait); @@ -73,7 +73,7 @@ public virtual IMessageDefinitionBuilder WithTrait(MessageTraitDefinition trait) public virtual IMessageDefinitionBuilder WithTraitReference(string reference) { if (string.IsNullOrWhiteSpace(reference)) throw new ArgumentNullException(nameof(reference)); - return this.WithTrait(new MessageTraitDefinition() { Reference = reference }); + return this.WithTrait(new V2MessageTraitDefinition() { Reference = reference }); } } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitBuilder.cs index 8bd1815..99c715f 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitBuilder.cs @@ -19,14 +19,14 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// Represents the default implementation of the interface /// public class MessageTraitBuilder - : MessageTraitDefinitionBuilder, IMessageTraitBuilder + : MessageTraitDefinitionBuilder, IMessageTraitBuilder { /// /// Initializes a new /// /// The current - /// An containing the services used to validate s - public MessageTraitBuilder(IServiceProvider serviceProvider, IEnumerable> validators) : base(serviceProvider, validators) { } + /// An containing the services used to validate s + public MessageTraitBuilder(IServiceProvider serviceProvider, IEnumerable> validators) : base(serviceProvider, validators) { } } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitDefinitionBuilder.cs index b5d43b5..a745f6a 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitDefinitionBuilder.cs @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.Bindings; using Neuroglia.Data.Schemas.Json; namespace Neuroglia.AsyncApi.FluentBuilders; @@ -19,18 +20,18 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// Represents the base class for all implementations /// /// The type of to return for chaining purposes -/// The type of to build +/// The type of to build public abstract class MessageTraitDefinitionBuilder : IMessageTraitDefinitionBuilder where TBuilder : IMessageTraitDefinitionBuilder - where TTrait : MessageTraitDefinition, new() + where TTrait : V2MessageTraitDefinition, new() { /// /// Initializes a new /// /// The current - /// An containing the services used to validate s + /// An containing the services used to validate s protected MessageTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) { this.ServiceProvider = serviceProvider; @@ -43,12 +44,12 @@ protected MessageTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnume protected IServiceProvider ServiceProvider { get; } /// - /// Gets an containing the services used to validate s + /// Gets an containing the services used to validate s /// protected IEnumerable> Validators { get; } /// - /// Gets the to configure + /// Gets the to configure /// protected virtual TTrait Trait { get; } = new(); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionBuilder.cs index c29328b..d5a162e 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionBuilder.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.FluentBuilders; /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionCollectionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionCollectionBuilder.cs index 6747f06..ba0d95d 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionCollectionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionCollectionBuilder.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.FluentBuilders; /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/OperationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/OperationDefinitionBuilder.cs index 62bdbd3..c83a8d0 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/OperationDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/OperationDefinitionBuilder.cs @@ -20,9 +20,9 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// Initializes a new /// /// The current -/// An containing the services used to validate s -public class OperationDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : OperationTraitDefinitionBuilder(serviceProvider, validators), IOperationDefinitionBuilder +/// An containing the services used to validate s +public class OperationDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : OperationTraitDefinitionBuilder(serviceProvider, validators), IOperationDefinitionBuilder { /// @@ -32,7 +32,7 @@ public virtual IOperationDefinitionBuilder WithMessage(Action(this.ServiceProvider); setup(builder); - this.Trait.Message = OperationMessageDefinition.From(builder.Build()); + this.Trait.Message = V2OperationMessageDefinition.From(builder.Build()); return this; } @@ -48,7 +48,7 @@ public virtual IOperationDefinitionBuilder WithMessages(params Action(this.ServiceProvider); setup(builder); - return OperationMessageDefinition.From(builder.Build()); + return V2OperationMessageDefinition.From(builder.Build()); })) }; diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitBuilder.cs index d0298a1..cfcc229 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitBuilder.cs @@ -22,8 +22,8 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// Initializes a new /// /// The current -/// An containing the services used to validate s -public class OperationTraitBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : OperationTraitDefinitionBuilder(serviceProvider, validators), IOperationTraitBuilder +/// An containing the services used to validate s +public class OperationTraitBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : OperationTraitDefinitionBuilder(serviceProvider, validators), IOperationTraitBuilder { } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitDefinitionBuilder.cs index fb625ef..cfd875e 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitDefinitionBuilder.cs @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.Bindings; using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; namespace Neuroglia.AsyncApi.FluentBuilders; @@ -20,18 +20,18 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// Represents the base class for all implementations /// /// The type of to return for chaining purposes -/// The type of to build +/// The type of to build public abstract class OperationTraitDefinitionBuilder : IOperationTraitDefinitionBuilder where TBuilder : IOperationTraitDefinitionBuilder - where TTrait : OperationTraitDefinition, new() + where TTrait : V2OperationTraitDefinition, new() { /// /// Initializes a new /// /// The current - /// An containing the services used to validate s + /// An containing the services used to validate s protected OperationTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) { this.ServiceProvider = serviceProvider; @@ -44,12 +44,12 @@ protected OperationTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnu protected IServiceProvider ServiceProvider { get; } /// - /// Gets an containing the services used to validate s + /// Gets an containing the services used to validate s /// protected IEnumerable> Validators { get; } /// - /// Gets the to configure + /// Gets the to configure /// protected virtual TTrait Trait { get; } = new(); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/ParameterDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/ParameterDefinitionBuilder.cs index 329e106..a340c17 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/ParameterDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/ParameterDefinitionBuilder.cs @@ -22,8 +22,8 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// Initializes a new /// /// The current -/// The services used to validate s -public class ParameterDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) +/// The services used to validate s +public class ParameterDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) : IParameterDefinitionBuilder { @@ -33,14 +33,14 @@ public class ParameterDefinitionBuilder(IServiceProvider serviceProvider, IEnume protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; /// - /// Gets the services used to validate s + /// Gets the services used to validate s /// - protected virtual IEnumerable> Validators { get; } = validators; + protected virtual IEnumerable> Validators { get; } = validators; /// - /// Gets the to configure + /// Gets the to configure /// - protected virtual ParameterDefinition Parameter { get; } = new(); + protected virtual V2ParameterDefinition Parameter { get; } = new(); /// public virtual IParameterDefinitionBuilder OfType() => this.OfType(typeof(TParameter)); @@ -75,7 +75,7 @@ public virtual IParameterDefinitionBuilder WithLocation(string location) } /// - public virtual ParameterDefinition Build() + public virtual V2ParameterDefinition Build() { var validationResults = this.Validators.Select(v => v.Validate(this.Parameter)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/RuntimeExpressionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/RuntimeExpressionBuilder.cs index 99bf7fa..66e9902 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/RuntimeExpressionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/RuntimeExpressionBuilder.cs @@ -12,7 +12,6 @@ // limitations under the License. using Neuroglia.AsyncApi.FluentBuilders; -using Neuroglia.AsyncApi.v2; namespace Neuroglia.AsyncApi.FluentBuilders; diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/SecuritySchemeDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/SecuritySchemeDefinitionBuilder.cs index 275c9e8..2520643 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/SecuritySchemeDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/SecuritySchemeDefinitionBuilder.cs @@ -11,16 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.FluentBuilders; /// /// Represents the default implementation of the interface /// /// The current -/// An containing the s used to validate built s -public class SecuritySchemeDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) +/// An containing the s used to validate built s +public class SecuritySchemeDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) : ISecuritySchemeDefinitionBuilder { @@ -30,14 +28,14 @@ public class SecuritySchemeDefinitionBuilder(IServiceProvider serviceProvider, I protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; /// - /// Gets the services used to validate s + /// Gets the services used to validate s /// - protected virtual IEnumerable> Validators { get; } = validators; + protected virtual IEnumerable> Validators { get; } = validators; /// - /// Gets the to configure + /// Gets the to configure /// - protected SecuritySchemeDefinition SecurityScheme { get; } = new(); + protected V2SecuritySchemeDefinition SecurityScheme { get; } = new(); /// public virtual ISecuritySchemeDefinitionBuilder WithType(SecuritySchemeType type) @@ -116,7 +114,7 @@ public virtual ISecuritySchemeDefinitionBuilder WithOpenIdConnectUrl(Uri? uri) } /// - public virtual SecuritySchemeDefinition Build() + public virtual V2SecuritySchemeDefinition Build() { var validationResults = this.Validators.Select(v => v.Validate(this.SecurityScheme)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/ServerDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/ServerDefinitionBuilder.cs index 7a5b588..9b6d0c6 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/ServerDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/ServerDefinitionBuilder.cs @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.Bindings; using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings; namespace Neuroglia.AsyncApi.FluentBuilders; @@ -23,8 +23,8 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// Initializes a new /// /// The current -/// The services used to validate s -public class ServerDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) +/// The services used to validate s +public class ServerDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) : IServerDefinitionBuilder { @@ -34,14 +34,14 @@ public class ServerDefinitionBuilder(IServiceProvider serviceProvider, IEnumerab protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; /// - /// Gets the services used to validate s + /// Gets the services used to validate s /// - protected virtual IEnumerable> Validators { get; } = validators; + protected virtual IEnumerable> Validators { get; } = validators; /// - /// Gets the to configure + /// Gets the to configure /// - protected virtual ServerDefinition Server { get; } = new(); + protected virtual V2ServerDefinition Server { get; } = new(); /// public virtual IServerDefinitionBuilder WithUrl(Uri uri) @@ -97,7 +97,7 @@ public virtual IServerDefinitionBuilder WithSecurityRequirement(string name, obj } /// - public virtual ServerDefinition Build() + public virtual V2ServerDefinition Build() { var validationResults = this.Validators.Select(v => v.Validate(this.Server)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/TagDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/TagDefinitionBuilder.cs index b2f8caa..accf9e0 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/TagDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/TagDefinitionBuilder.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.FluentBuilders; /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/VariableDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/VariableDefinitionBuilder.cs index 83eb1e9..f601fd6 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/VariableDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/VariableDefinitionBuilder.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.FluentBuilders; /// @@ -21,20 +19,20 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// /// Initializes a new /// -/// The services used to validate s -public class VariableDefinitionBuilder(IEnumerable> validators) +/// The services used to validate s +public class VariableDefinitionBuilder(IEnumerable> validators) : IVariableDefinitionBuilder { /// - /// Gets the services used to validate s + /// Gets the services used to validate s /// - protected virtual IEnumerable> Validators { get; } = validators; + protected virtual IEnumerable> Validators { get; } = validators; /// - /// Gets the to build + /// Gets the to build /// - protected VariableDefinition Variable { get; } = new(); + protected ServerVariableDefinition Variable { get; } = new(); /// public virtual IVariableDefinitionBuilder WithEnumValues(params string[] values) @@ -67,6 +65,6 @@ public virtual IVariableDefinitionBuilder WithExample(string example) } /// - public virtual VariableDefinition Build() => this.Variable; + public virtual ServerVariableDefinition Build() => this.Variable; } diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerationOptions.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerationOptions.cs index c972fda..ed071a9 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerationOptions.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerationOptions.cs @@ -16,13 +16,13 @@ namespace Neuroglia.AsyncApi.Generation; /// -/// Represents the options used to configure generation +/// Represents the options used to configure generation /// public class AsyncApiDocumentGenerationOptions { /// - /// Gets/sets an used to configure the s to configure + /// Gets/sets an used to configure the s to configure /// public Action? DefaultConfiguration { get; set; } diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.cs index 420c701..d9abab7 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.cs @@ -38,7 +38,7 @@ public class AsyncApiDocumentGenerator(IServiceProvider serviceProvider, IJsonSc protected IJsonSchemaExampleGenerator ExampleGenerator { get; } = exampleGenerator; /// - public virtual async Task> GenerateAsync(IEnumerable markupTypes, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) + public virtual async Task> GenerateAsync(IEnumerable markupTypes, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(markupTypes); @@ -46,20 +46,20 @@ public virtual async Task> GenerateAsync(IEnumerab .Select(t => t.Assembly) .Distinct() .SelectMany(t => t.GetTypes()).Where(t => t.GetCustomAttribute() != null); - var documents = new List(types.Count()); + var documents = new List(types.Count()); foreach (var type in types) documents.Add(await this.GenerateDocumentForAsync(type, options, cancellationToken).ConfigureAwait(false)); return documents; } /// - /// Generates a new for the specified type + /// Generates a new for the specified type /// - /// The type to generate a code-first for + /// The type to generate a code-first for /// The to use /// A - /// A new - protected virtual async Task GenerateDocumentForAsync(Type type, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) + /// A new + protected virtual async Task GenerateDocumentForAsync(Type type, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(type); @@ -85,11 +85,11 @@ protected virtual async Task GenerateDocumentForAsync(Type typ } /// - /// Builds a new + /// Builds a new /// /// The to configure - /// The attribute used to describe the to configure - /// A containing the 's s s + /// The attribute used to describe the to configure + /// A containing the 's s s /// The to use /// A /// A new awaitable @@ -126,11 +126,11 @@ protected virtual async Task ConfigureChannelForAsync(IAsyncApiDocumentBuilder b } /// - /// Configures and builds a new for the specified + /// Configures and builds a new for the specified /// /// The to configure - /// The attribute used to describe the to configure - /// The marked with the specified attribute + /// The attribute used to describe the to configure + /// The marked with the specified attribute /// The to use protected virtual void ConfigureOperationMessageFor(IMessageDefinitionBuilder messageBuilder, OperationAttribute operation, MethodInfo operationMethod, AsyncApiDocumentGenerationOptions options) { diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentProvider.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentProvider.cs index a6fcf30..c55b273 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentProvider.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentProvider.cs @@ -22,8 +22,8 @@ namespace Neuroglia.AsyncApi; /// Represents the default implementation of the interface /// /// The current -/// The options used to configure how to generate code-first s -/// The service used to generate code-first s +/// The options used to configure how to generate code-first s +/// The service used to generate code-first s public class AsyncApiDocumentProvider(IServiceProvider serviceProvider, IOptions generationOptions, IAsyncApiDocumentGenerator generator) : IHostedService, IAsyncApiDocumentProvider { @@ -34,24 +34,24 @@ public class AsyncApiDocumentProvider(IServiceProvider serviceProvider, IOptions protected IServiceProvider ServiceProvider { get; } = serviceProvider; /// - /// Gets the options used to configure how to generate code-first s + /// Gets the options used to configure how to generate code-first s /// protected AsyncApiGenerationOptions GenerationOptions { get; } = generationOptions.Value; /// - /// Gets the service used to generate code-first s + /// Gets the service used to generate code-first s /// protected IAsyncApiDocumentGenerator Generator { get; } = generator; /// - /// Gets a containing all known s + /// Gets a containing all known s /// - protected List? Documents { get; private set; } + protected List? Documents { get; private set; } /// public virtual async Task StartAsync(CancellationToken cancellationToken) { - this.Documents = this.ServiceProvider.GetService>()?.ToList() ?? []; + this.Documents = this.ServiceProvider.GetService>()?.ToList() ?? []; this.Documents.AddRange((await this.Generator.GenerateAsync(this.GenerationOptions.MarkupTypes, new AsyncApiDocumentGenerationOptions() { DefaultConfiguration = this.GenerationOptions.DefaultDocumentConfiguration }, cancellationToken).ConfigureAwait(false)).ToList()); } @@ -59,16 +59,16 @@ public virtual async Task StartAsync(CancellationToken cancellationToken) public virtual Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; /// - public virtual Task GetDocumentAsync(string title, string version, CancellationToken cancellationToken = default) + public virtual Task GetDocumentAsync(string title, string version, CancellationToken cancellationToken = default) { return Task.FromResult(this.Documents!.FirstOrDefault(d => (d.Info.Title.Equals(title, StringComparison.OrdinalIgnoreCase) || d.Info.Title.ToKebabCase().Equals(title, StringComparison.OrdinalIgnoreCase)) && d.Info.Version.Equals(version, StringComparison.OrdinalIgnoreCase))); } /// - public virtual Task GetDocumentAsync(string id, CancellationToken cancellationToken = default) => Task.FromResult(this.Documents!.FirstOrDefault(d => !string.IsNullOrWhiteSpace(d.Id) && d.Id.Equals(id, StringComparison.OrdinalIgnoreCase))); + public virtual Task GetDocumentAsync(string id, CancellationToken cancellationToken = default) => Task.FromResult(this.Documents!.FirstOrDefault(d => !string.IsNullOrWhiteSpace(d.Id) && d.Id.Equals(id, StringComparison.OrdinalIgnoreCase))); /// - public virtual IEnumerator GetEnumerator() => this.Documents?.GetEnumerator() ?? new List().GetEnumerator(); + public virtual IEnumerator GetEnumerator() => this.Documents?.GetEnumerator() ?? new List().GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator(); diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptions.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptions.cs index 8cae2f0..fa09dc6 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptions.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptions.cs @@ -27,7 +27,7 @@ public class AsyncApiGenerationOptions public virtual List MarkupTypes { get; set; } = []; /// - /// Gets/sets the used to apply a default configuration to generated s + /// Gets/sets the used to apply a default configuration to generated s /// public virtual Action? DefaultDocumentConfiguration { get; set; } diff --git a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentGenerator.cs b/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentGenerator.cs index 9eb9337..647a62c 100644 --- a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentGenerator.cs +++ b/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentGenerator.cs @@ -16,18 +16,18 @@ namespace Neuroglia.AsyncApi.Generation; /// -/// Defines the fundamentals of a service used to generate s in a code-first fashion +/// Defines the fundamentals of a service used to generate s in a code-first fashion /// public interface IAsyncApiDocumentGenerator { /// - /// Generates code-first s for types reflected in the specified assemblies + /// Generates code-first s for types reflected in the specified assemblies /// /// An containing the mark up types belonging to the assemblies to scan /// The to use /// A - /// An containing the generated s - Task> GenerateAsync(IEnumerable markupTypes, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default); + /// An containing the generated s + Task> GenerateAsync(IEnumerable markupTypes, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default); } diff --git a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentProvider.cs b/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentProvider.cs index f96edb6..6830026 100644 --- a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentProvider.cs +++ b/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentProvider.cs @@ -14,27 +14,27 @@ namespace Neuroglia.AsyncApi.Generation; /// -/// Defines the fundamentals of a service used to manage s +/// Defines the fundamentals of a service used to manage s /// public interface IAsyncApiDocumentProvider - : IEnumerable + : IEnumerable { /// - /// Gets the with the specified title and version + /// Gets the with the specified title and version /// - /// The title of the to get - /// The version of the to get + /// The title of the to get + /// The version of the to get /// A - /// The with the specified title and version, if any - Task GetDocumentAsync(string title, string version, CancellationToken cancellationToken = default); + /// The with the specified title and version, if any + Task GetDocumentAsync(string title, string version, CancellationToken cancellationToken = default); /// - /// Gets the with the specified id + /// Gets the with the specified id /// - /// The id of the to get + /// The id of the to get /// A - /// The with the specified id, if any - Task GetDocumentAsync(string id, CancellationToken cancellationToken = default); + /// The with the specified id, if any + Task GetDocumentAsync(string id, CancellationToken cancellationToken = default); } diff --git a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiGenerationOptionsBuilder.cs b/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiGenerationOptionsBuilder.cs index c5fc950..36d4263 100644 --- a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiGenerationOptionsBuilder.cs +++ b/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiGenerationOptionsBuilder.cs @@ -36,9 +36,9 @@ public interface IAsyncApiGenerationOptionsBuilder IAsyncApiGenerationOptionsBuilder WithMarkupType(); /// - /// Configures the to use the specified to setup the default configuration for generated s + /// Configures the to use the specified to setup the default configuration for generated s /// - /// The used to configure the used to build s + /// The used to configure the used to build s /// The configured IAsyncApiGenerationOptionsBuilder UseDefaultConfiguration(Action configurationAction); diff --git a/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentReader.cs b/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentReader.cs index 0b40fdd..98a66eb 100644 --- a/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentReader.cs +++ b/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentReader.cs @@ -39,7 +39,7 @@ public class AsyncApiDocumentReader(IJsonSerializer jsonSerializer, IYamlSeriali protected IYamlSerializer YamlSerializer { get; } = yamlSerializer; /// - public virtual async Task ReadAsync(Stream stream, CancellationToken cancellationToken = default) + public virtual async Task ReadAsync(Stream stream, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(stream); var offset = stream.Position; @@ -47,14 +47,14 @@ public class AsyncApiDocumentReader(IJsonSerializer jsonSerializer, IYamlSeriali string input = reader.ReadToEnd(); stream.Position = offset; var serializer = this.ResolveDocumentFormat(input) == AsyncApiDocumentFormat.Json ? (ITextSerializer)this.JsonSerializer : this.YamlSerializer; - return serializer is IAsyncSerializer asyncSerializer ? await asyncSerializer.DeserializeAsync(stream, cancellationToken) : serializer.Deserialize(stream); + return serializer is IAsyncSerializer asyncSerializer ? await asyncSerializer.DeserializeAsync(stream, cancellationToken) : serializer.Deserialize(stream); } /// - /// Resolves the of the specified raw + /// Resolves the of the specified raw /// - /// The raw to get the format of - /// The of the specified raw + /// The raw to get the format of + /// The of the specified raw protected virtual AsyncApiDocumentFormat ResolveDocumentFormat(string input) => input.TrimStart().StartsWith('{') && input.TrimEnd().EndsWith('}') ? AsyncApiDocumentFormat.Json : AsyncApiDocumentFormat.Yaml; } diff --git a/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentWriter.cs b/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentWriter.cs index 6f23e72..67e131a 100644 --- a/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentWriter.cs +++ b/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentWriter.cs @@ -39,7 +39,7 @@ public class AsyncApiDocumentWriter(IJsonSerializer jsonSerializer, IYamlSeriali protected IYamlSerializer YamlSerializer { get; } = yamlSerializer; /// - public virtual async Task WriteAsync(AsyncApiDocument document, Stream stream, AsyncApiDocumentFormat format = AsyncApiDocumentFormat.Yaml, CancellationToken cancellationToken = default) + public virtual async Task WriteAsync(V2AsyncApiDocument document, Stream stream, AsyncApiDocumentFormat format = AsyncApiDocumentFormat.Yaml, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(document); ArgumentNullException.ThrowIfNull(stream); @@ -47,11 +47,11 @@ public virtual async Task WriteAsync(AsyncApiDocument document, Stream stream, A switch (format) { case AsyncApiDocumentFormat.Json: - if (this.JsonSerializer is IAsyncSerializer asyncJsonSerializer) await asyncJsonSerializer.SerializeAsync(stream, document, typeof(AsyncApiDocument), cancellationToken).ConfigureAwait(false); + if (this.JsonSerializer is IAsyncSerializer asyncJsonSerializer) await asyncJsonSerializer.SerializeAsync(stream, document, typeof(V2AsyncApiDocument), cancellationToken).ConfigureAwait(false); else this.JsonSerializer.Serialize(document, stream); break; case AsyncApiDocumentFormat.Yaml: - if (this.YamlSerializer is IAsyncSerializer asyncYamlSerializer) await asyncYamlSerializer.SerializeAsync(stream, document, typeof(AsyncApiDocument), cancellationToken).ConfigureAwait(false); + if (this.YamlSerializer is IAsyncSerializer asyncYamlSerializer) await asyncYamlSerializer.SerializeAsync(stream, document, typeof(V2AsyncApiDocument), cancellationToken).ConfigureAwait(false); else this.YamlSerializer.Serialize(document, stream); break; default: diff --git a/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentReader.cs b/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentReader.cs index 71ce776..ffe183a 100644 --- a/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentReader.cs +++ b/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentReader.cs @@ -16,17 +16,17 @@ namespace Neuroglia.AsyncApi.IO; /// -/// Defines the fundamentals of a service used to read s +/// Defines the fundamentals of a service used to read s /// public interface IAsyncApiDocumentReader { /// - /// Reads a from the specified + /// Reads a from the specified /// - /// The to read the from + /// The to read the from /// A - /// A new - Task ReadAsync(Stream stream, CancellationToken cancellationToken = default); + /// A new + Task ReadAsync(Stream stream, CancellationToken cancellationToken = default); } diff --git a/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentWriter.cs b/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentWriter.cs index 3ee03cb..16bdcea 100644 --- a/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentWriter.cs +++ b/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentWriter.cs @@ -16,19 +16,19 @@ namespace Neuroglia.AsyncApi.IO; /// -/// Defines the fundamentals of a service used to write s +/// Defines the fundamentals of a service used to write s /// public interface IAsyncApiDocumentWriter { /// - /// Writes the specified to a + /// Writes the specified to a /// - /// The to write - /// The to read the from - /// The format of the to read. Defaults to '' + /// The to write + /// The to read the from + /// The format of the to read. Defaults to '' /// A - /// A new - Task WriteAsync(AsyncApiDocument document, Stream stream, AsyncApiDocumentFormat format = AsyncApiDocumentFormat.Yaml, CancellationToken cancellationToken = default); + /// A new + Task WriteAsync(V2AsyncApiDocument document, Stream stream, AsyncApiDocumentFormat format = AsyncApiDocumentFormat.Yaml, CancellationToken cancellationToken = default); } diff --git a/src/Neuroglia.AsyncApi.Validation/v2/AsyncApiDocumentValidator.cs b/src/Neuroglia.AsyncApi.Validation/v2/AsyncApiDocumentValidator.cs index 0f48629..b478b49 100644 --- a/src/Neuroglia.AsyncApi.Validation/v2/AsyncApiDocumentValidator.cs +++ b/src/Neuroglia.AsyncApi.Validation/v2/AsyncApiDocumentValidator.cs @@ -16,10 +16,10 @@ namespace Neuroglia.AsyncApi.Validation; /// -/// Represents the service used to validate s +/// Represents the service used to validate s /// public class AsyncApiDocumentValidator - : AbstractValidator + : AbstractValidator { /// diff --git a/src/Neuroglia.AsyncApi.Validation/v2/ChannelValidator.cs b/src/Neuroglia.AsyncApi.Validation/v2/ChannelValidator.cs index 844ac81..16c6363 100644 --- a/src/Neuroglia.AsyncApi.Validation/v2/ChannelValidator.cs +++ b/src/Neuroglia.AsyncApi.Validation/v2/ChannelValidator.cs @@ -16,10 +16,10 @@ namespace Neuroglia.AsyncApi.Validation; /// -/// Represents the service used to validate s +/// Represents the service used to validate s /// public class ChannelValidator - : AbstractValidator + : AbstractValidator { /// diff --git a/src/Neuroglia.AsyncApi.Validation/v2/ComponentsValidator.cs b/src/Neuroglia.AsyncApi.Validation/v2/ComponentsValidator.cs index 8711c7d..089f735 100644 --- a/src/Neuroglia.AsyncApi.Validation/v2/ComponentsValidator.cs +++ b/src/Neuroglia.AsyncApi.Validation/v2/ComponentsValidator.cs @@ -16,10 +16,10 @@ namespace Neuroglia.AsyncApi.Validation; /// -/// Represents the service used to validate the +/// Represents the service used to validate the /// public class ComponentsValidator - : AbstractValidator + : AbstractValidator { /// diff --git a/src/Neuroglia.AsyncApi.Validation/v2/InfoValidator.cs b/src/Neuroglia.AsyncApi.Validation/v2/InfoValidator.cs index 18895d5..bb35a49 100644 --- a/src/Neuroglia.AsyncApi.Validation/v2/InfoValidator.cs +++ b/src/Neuroglia.AsyncApi.Validation/v2/InfoValidator.cs @@ -16,10 +16,10 @@ namespace Neuroglia.AsyncApi.Validation; /// -/// Represents the service used to validate the +/// Represents the service used to validate the /// public class InfoValidator - : AbstractValidator + : AbstractValidator { /// diff --git a/src/Neuroglia.AsyncApi.Validation/v2/LicenseValidator.cs b/src/Neuroglia.AsyncApi.Validation/v2/LicenseValidator.cs index e55c73b..4953eb2 100644 --- a/src/Neuroglia.AsyncApi.Validation/v2/LicenseValidator.cs +++ b/src/Neuroglia.AsyncApi.Validation/v2/LicenseValidator.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.Validation; /// diff --git a/src/Neuroglia.AsyncApi.Validation/v2/MessageTraitValidator.cs b/src/Neuroglia.AsyncApi.Validation/v2/MessageTraitValidator.cs index a1b280e..ebc4b87 100644 --- a/src/Neuroglia.AsyncApi.Validation/v2/MessageTraitValidator.cs +++ b/src/Neuroglia.AsyncApi.Validation/v2/MessageTraitValidator.cs @@ -16,10 +16,10 @@ namespace Neuroglia.AsyncApi.Validation; /// -/// Represents the service used to validate s +/// Represents the service used to validate s /// public class MessageTraitValidator - : AbstractValidator + : AbstractValidator { /// diff --git a/src/Neuroglia.AsyncApi.Validation/v2/MessageValidator.cs b/src/Neuroglia.AsyncApi.Validation/v2/MessageValidator.cs index 83d00cd..a6401ef 100644 --- a/src/Neuroglia.AsyncApi.Validation/v2/MessageValidator.cs +++ b/src/Neuroglia.AsyncApi.Validation/v2/MessageValidator.cs @@ -16,10 +16,10 @@ namespace Neuroglia.AsyncApi.Validation; /// -/// Represents the service used to validate s +/// Represents the service used to validate s /// public class MessageValidator - : AbstractValidator + : AbstractValidator { /// diff --git a/src/Neuroglia.AsyncApi.Validation/v2/OperationTraitValidator.cs b/src/Neuroglia.AsyncApi.Validation/v2/OperationTraitValidator.cs index e0eeb15..0595ae4 100644 --- a/src/Neuroglia.AsyncApi.Validation/v2/OperationTraitValidator.cs +++ b/src/Neuroglia.AsyncApi.Validation/v2/OperationTraitValidator.cs @@ -16,10 +16,10 @@ namespace Neuroglia.AsyncApi.Validation; /// -/// Represents the service used to validate s +/// Represents the service used to validate s /// public class OperationTraitValidator - : AbstractValidator + : AbstractValidator { /// diff --git a/src/Neuroglia.AsyncApi.Validation/v2/OperationValidator.cs b/src/Neuroglia.AsyncApi.Validation/v2/OperationValidator.cs index a31680c..2ad46fa 100644 --- a/src/Neuroglia.AsyncApi.Validation/v2/OperationValidator.cs +++ b/src/Neuroglia.AsyncApi.Validation/v2/OperationValidator.cs @@ -16,10 +16,10 @@ namespace Neuroglia.AsyncApi.Validation; /// -/// Represents the service used to validate s +/// Represents the service used to validate s /// public class OperationValidator - : AbstractValidator + : AbstractValidator { /// diff --git a/src/Neuroglia.AsyncApi.Validation/v2/ServerValidator.cs b/src/Neuroglia.AsyncApi.Validation/v2/ServerValidator.cs index 7910dd6..997ac54 100644 --- a/src/Neuroglia.AsyncApi.Validation/v2/ServerValidator.cs +++ b/src/Neuroglia.AsyncApi.Validation/v2/ServerValidator.cs @@ -16,10 +16,10 @@ namespace Neuroglia.AsyncApi.Validation; /// -/// Represents the service used to validate s +/// Represents the service used to validate s /// public class ServerValidator - : AbstractValidator + : AbstractValidator { /// diff --git a/src/Neuroglia.AsyncApi.Validation/v2/TagValidator.cs b/src/Neuroglia.AsyncApi.Validation/v2/TagValidator.cs index 39f7278..f60aafa 100644 --- a/src/Neuroglia.AsyncApi.Validation/v2/TagValidator.cs +++ b/src/Neuroglia.AsyncApi.Validation/v2/TagValidator.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.Validation; /// diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/AsyncApiDocumentSerializationTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/AsyncApiDocumentSerializationTests.cs index c33bcef..2c1eec5 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/AsyncApiDocumentSerializationTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/AsyncApiDocumentSerializationTests.cs @@ -28,10 +28,10 @@ public void SerializeAndDeserialize_AsyncApiDocument_Should_Work() //act var json = JsonSerializer.Default.SerializeToText(document); - var jsonDeserialized = JsonSerializer.Default.Deserialize(json); + var jsonDeserialized = JsonSerializer.Default.Deserialize(json); var yaml = YamlSerializer.Default.SerializeToText(document); - var yamlDeserialized = YamlSerializer.Default.Deserialize(yaml); + var yamlDeserialized = YamlSerializer.Default.Deserialize(yaml); //assert jsonDeserialized.Should().Be(document); diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/RuntimeExpressionTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/RuntimeExpressionTests.cs index 5615bdf..f05ae75 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/RuntimeExpressionTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/RuntimeExpressionTests.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.UnitTests.Cases.Core; public class RuntimeExpressionTests diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs index fa6e050..1e2e881 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs @@ -16,7 +16,6 @@ using Microsoft.Extensions.DependencyInjection; using Neuroglia.AsyncApi.FluentBuilders; using Neuroglia.AsyncApi.v2.Bindings.Http; -using Neuroglia.AsyncApi.v2; using System.Net.Mime; namespace Neuroglia.AsyncApi.UnitTests.Cases.Fluent; diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs b/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs index a7f505c..f93b9ce 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.Bindings.Mqtt; using Neuroglia.AsyncApi.v2; -using Neuroglia.AsyncApi.v2.Bindings.Mqtt; using System.Net.Mime; namespace Neuroglia.AsyncApi.UnitTests.Services; @@ -20,9 +20,9 @@ namespace Neuroglia.AsyncApi.UnitTests.Services; internal static class AsyncApiDocumentFactory { - public static AsyncApiDocument Create() + public static V2AsyncApiDocument Create() { - return new AsyncApiDocument() + return new V2AsyncApiDocument() { AsyncApi = AsyncApiSpecVersion.V2, Id = "fake-document", @@ -46,7 +46,7 @@ public static AsyncApiDocument Create() { { "fake-server", - new ServerDefinition() + new V2ServerDefinition() { Url = new("https://fake.contact.com"), Description = "Fake AsyncAPI server", @@ -85,7 +85,7 @@ public static AsyncApiDocument Create() { { "fake-channel", - new ChannelDefinition() + new V2ChannelDefinition() { Publish = new() { From a6306d8269ae2432bb9f8e6ab71a202e3ff4b40b Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Tue, 17 Dec 2024 12:39:45 +0100 Subject: [PATCH 02/21] fix(Core): Fixed the `V2MessageTraitDefinition` by adding missing `messageId` property Fixes #37 Signed-off-by: Charles d'Avernas --- .../v2/V2MessageTraitDefinition.cs | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/Neuroglia.AsyncApi.Core/v2/V2MessageTraitDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2MessageTraitDefinition.cs index 4d55420..c91391c 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/V2MessageTraitDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2MessageTraitDefinition.cs @@ -21,16 +21,25 @@ public record V2MessageTraitDefinition : ReferenceableComponentDefinition { + /// + /// Gets/sets a unique string used to identify the message. + /// The id MUST be unique among all messages described in the API. + /// The messageId value is case-sensitive. + /// Tools and libraries MAY use the messageId to uniquely identify a message, therefore, it is RECOMMENDED to follow common programming naming conventions. + /// + [DataMember(Order = 1, Name = "messageId"), JsonPropertyOrder(1), JsonPropertyName("messageId"), YamlMember(Order = 1, Alias = "messageId")] + public virtual string? MessageId { get; set; } + /// /// Gets/sets a of the application headers. Schema MUST be of type "object". It MUST NOT define the protocol headers. /// - [DataMember(Order = 1, Name = "headers"), JsonPropertyOrder(1), JsonPropertyName("headers"), YamlMember(Order = 1, Alias = "headers")] + [DataMember(Order = 2, Name = "headers"), JsonPropertyOrder(2), JsonPropertyName("headers"), YamlMember(Order = 2, Alias = "headers")] public virtual JsonSchema? Headers { get; set; } /// /// Gets/sets the definition of the correlation ID used for message tracing or matching. /// - [DataMember(Order = 2, Name = "correlationId"), JsonPropertyOrder(2), JsonPropertyName("correlationId"), YamlMember(Order = 2, Alias = "correlationId")] + [DataMember(Order = 3, Name = "correlationId"), JsonPropertyOrder(3), JsonPropertyName("correlationId"), YamlMember(Order = 3, Alias = "correlationId")] public virtual CorrelationIdDefinition? CorrelationId { get; set; } /// @@ -38,55 +47,55 @@ public record V2MessageTraitDefinition /// If omitted, implementations should parse the payload as a . /// When the payload is defined using a $ref to a remote file, it is RECOMMENDED the schema format includes the file encoding type to allow implementations to parse the file correctly. E.g., adding +yaml if content type is application/vnd.apache.avro results in application/vnd.apache.avro+yaml. /// - [DataMember(Order = 3, Name = "schemaFormat"), JsonPropertyOrder(3), JsonPropertyName("schemaFormat"), YamlMember(Order = 3, Alias = "schemaFormat")] + [DataMember(Order = 4, Name = "schemaFormat"), JsonPropertyOrder(4), JsonPropertyName("schemaFormat"), YamlMember(Order = 4, Alias = "schemaFormat")] public virtual string? SchemaFormat { get; set; } /// /// Gets/sets the content type to use when encoding/decoding a message's payload. The value MUST be a specific media type (e.g. application/json). When omitted, the value MUST be the one specified on the property. /// - [DataMember(Order = 4, Name = "contentType"), JsonPropertyOrder(4), JsonPropertyName("contentType"), YamlMember(Order = 4, Alias = "contentType")] + [DataMember(Order = 5, Name = "contentType"), JsonPropertyOrder(5), JsonPropertyName("contentType"), YamlMember(Order = 5, Alias = "contentType")] public virtual string? ContentType { get; set; } /// /// Gets/sets a machine-friendly name for the message. /// - [DataMember(Order = 5, Name = "name"), JsonPropertyOrder(5), JsonPropertyName("name"), YamlMember(Order = 5, Alias = "name")] + [DataMember(Order = 6, Name = "name"), JsonPropertyOrder(6), JsonPropertyName("name"), YamlMember(Order = 6, Alias = "name")] public virtual string? Name { get; set; } /// /// Gets/sets a human-friendly title for the message. /// - [DataMember(Order = 6, Name = "title"), JsonPropertyOrder(6), JsonPropertyName("title"), YamlMember(Order = 6, Alias = "title")] + [DataMember(Order = 7, Name = "title"), JsonPropertyOrder(7), JsonPropertyName("title"), YamlMember(Order = 7, Alias = "title")] public virtual string? Title { get; set; } /// /// Gets/sets a short summary of what the message is about. /// - [DataMember(Order = 7, Name = "summary"), JsonPropertyOrder(7), JsonPropertyName("summary"), YamlMember(Order = 7, Alias = "summary")] + [DataMember(Order = 8, Name = "summary"), JsonPropertyOrder(8), JsonPropertyName("summary"), YamlMember(Order = 8, Alias = "summary")] public virtual string? Summary { get; set; } /// /// Gets/sets an optional description of the message. CommonMark syntax can be used for rich text representation. /// - [DataMember(Order = 8, Name = "description"), JsonPropertyOrder(8), JsonPropertyName("description"), YamlMember(Order = 8, Alias = "description")] + [DataMember(Order = 9, Name = "description"), JsonPropertyOrder(9), JsonPropertyName("description"), YamlMember(Order = 9, Alias = "description")] public virtual string? Description { get; set; } /// /// gets/sets a of tags for API documentation control. Tags can be used for logical grouping of operations. /// - [DataMember(Order = 9, Name = "tags"), JsonPropertyOrder(9), JsonPropertyName("tags"), YamlMember(Order = 9, Alias = "tags")] + [DataMember(Order = 10, Name = "tags"), JsonPropertyOrder(10), JsonPropertyName("tags"), YamlMember(Order = 10, Alias = "tags")] public virtual EquatableList? Tags { get; set; } /// /// Gets/sets an object containing additional external documentation for this message. /// - [DataMember(Order = 10, Name = "externalDocs"), JsonPropertyOrder(10), JsonPropertyName("externalDocs"), YamlMember(Order = 10, Alias = "externalDocs")] + [DataMember(Order = 11, Name = "externalDocs"), JsonPropertyOrder(11), JsonPropertyName("externalDocs"), YamlMember(Order = 11, Alias = "externalDocs")] public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } /// /// Gets/sets an object used to configure the 's s /// - [DataMember(Order = 11, Name = "bindings"), JsonPropertyOrder(11), JsonPropertyName("bindings"), YamlMember(Order = 11, Alias = "bindings")] + [DataMember(Order = 12, Name = "bindings"), JsonPropertyOrder(12), JsonPropertyName("bindings"), YamlMember(Order = 12, Alias = "bindings")] public virtual MessageBindingDefinitionCollection? Bindings { get; set; } /// @@ -94,7 +103,7 @@ public record V2MessageTraitDefinition /// Values MUST contain examples that validate against the headers or payload fields, respectively. /// Example MAY also have the name and summary additional keys to provide respectively a machine-friendly name and a short summary of what the example is about. /// - [DataMember(Order = 12, Name = "examples"), JsonPropertyOrder(12), JsonPropertyName("examples"), YamlMember(Order = 12, Alias = "examples")] + [DataMember(Order = 13, Name = "examples"), JsonPropertyOrder(13), JsonPropertyName("examples"), YamlMember(Order = 13, Alias = "examples")] public virtual EquatableDictionary? Examples { get; set; } /// From 84944282d1236815b1685d2df8571c556b76ff6b Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Tue, 17 Dec 2024 12:41:19 +0100 Subject: [PATCH 03/21] fix(Core): Fixed the AsyncApiAttribute by adding interfaces as attribute targets Fixes #38 Signed-off-by: Charles d'Avernas --- src/Neuroglia.AsyncApi.Core/Attributes/AsyncApiAttribute.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/AsyncApiAttribute.cs b/src/Neuroglia.AsyncApi.Core/Attributes/AsyncApiAttribute.cs index 9c5e0ce..fa24cc0 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/AsyncApiAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/Attributes/AsyncApiAttribute.cs @@ -18,7 +18,7 @@ namespace Neuroglia.AsyncApi; /// /// Represents an used to mark a class as an Async Api to generate a new for /// -[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] public class AsyncApiAttribute : Attribute { From 41493d365d6e57011a92e98682522d308d670c19 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Tue, 17 Dec 2024 13:15:55 +0100 Subject: [PATCH 04/21] fix(UnitTests): Fixed UnitTests Signed-off-by: Charles d'Avernas --- .../Messages/LightMeasuredEvent.cs | 5 ---- .../Messages/MovementDetectedEvent.cs | 21 ++++++--------- samples/StreetLightsApi/Messages/Todo.cs | 16 ++++++++++++ samples/StreetLightsApi/Program.cs | 9 +------ .../Services/MovementSensorService.cs | 10 ++----- .../Services/StreetLightsService.cs | 7 ----- .../Services/TemperatureSensorServiceV1.cs | 8 ------ .../Services/TemperatureSensorServiceV2.cs | 9 +------ samples/StreetLightsApi/Usings.cs | 26 +++++++++++++++++++ .../IbmMQ/IbmMQChannelBindingDefinition.cs | 3 --- .../Usings.cs | 1 - .../CloudEvents/CloudEventExtensionsTests.cs | 10 +------ .../AsyncApiDocumentSerializationTests.cs | 4 --- .../Cases/Fluent/FluentBuilderTests.cs | 7 +---- .../JsonSchemaExampleGeneratorTests.cs | 7 ----- .../Services/AsyncApiDocumentFactory.cs | 2 -- tests/Neuroglia.AsyncApi.UnitTests/Usings.cs | 13 ++++++++++ 17 files changed, 69 insertions(+), 89 deletions(-) create mode 100644 samples/StreetLightsApi/Messages/Todo.cs create mode 100644 samples/StreetLightsApi/Usings.cs diff --git a/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs b/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs index f787e55..83ba78b 100644 --- a/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs +++ b/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs @@ -11,9 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Json.Schema.Generation; -using Neuroglia.AsyncApi; - namespace StreetLightsApi.Server.Messages; [Tag("light", "A tag for light-related messages"), Tag("measurement", "A tag for measurement-related messages")] @@ -39,5 +36,3 @@ public class LightMeasuredEvent public List Todos { get; set; } } - -public record Todo(string Name); diff --git a/samples/StreetLightsApi/Messages/MovementDetectedEvent.cs b/samples/StreetLightsApi/Messages/MovementDetectedEvent.cs index 0bdcfbe..2eed046 100644 --- a/samples/StreetLightsApi/Messages/MovementDetectedEvent.cs +++ b/samples/StreetLightsApi/Messages/MovementDetectedEvent.cs @@ -11,22 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi; -using System.ComponentModel; +namespace StreetLightsApi.Server.Messages; -namespace StreetLightsApi.Server.Messages +[Tag("movement", "A tag for movement-related messages"), Tag("sensor", "A tag for sensor-related messages")] +[Message(Name = "MovementDetected")] +public class MovementDetectedEvent { - [Tag("movement", "A tag for movement-related messages"), Tag("sensor", "A tag for sensor-related messages")] - [Message(Name = "MovementDetected")] - public class MovementDetectedEvent - { - [Description("The id of the sensor that has detected movement")] - public int SensorId { get; set; } + [Description("The id of the sensor that has detected movement")] + public int SensorId { get; set; } - [Description("The date and time at which the event has been created")] - public DateTime SentAt { get; set; } - - } + [Description("The date and time at which the event has been created")] + public DateTime SentAt { get; set; } } diff --git a/samples/StreetLightsApi/Messages/Todo.cs b/samples/StreetLightsApi/Messages/Todo.cs new file mode 100644 index 0000000..fa82b9a --- /dev/null +++ b/samples/StreetLightsApi/Messages/Todo.cs @@ -0,0 +1,16 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace StreetLightsApi.Server.Messages; + +public record Todo(string Name); diff --git a/samples/StreetLightsApi/Program.cs b/samples/StreetLightsApi/Program.cs index 392e6b5..8f44274 100644 --- a/samples/StreetLightsApi/Program.cs +++ b/samples/StreetLightsApi/Program.cs @@ -11,14 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Json.Schema; -using Neuroglia.AsyncApi; -using Neuroglia.AsyncApi.Bindings.Http; -using Neuroglia.AsyncApi.v2.Bindings.Http; -using Neuroglia.AsyncApi.v2.Bindings.Mqtt; -using Neuroglia.Data.Schemas.Json; -using StreetLightsApi.Server.Services; -using System.Net.Mime; +using Neuroglia.AsyncApi.Bindings.Mqtt; var builder = WebApplication.CreateBuilder(args); diff --git a/samples/StreetLightsApi/Services/MovementSensorService.cs b/samples/StreetLightsApi/Services/MovementSensorService.cs index 13f488f..c1f4b31 100644 --- a/samples/StreetLightsApi/Services/MovementSensorService.cs +++ b/samples/StreetLightsApi/Services/MovementSensorService.cs @@ -11,19 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -using MQTTnet; -using MQTTnet.Client; -using Neuroglia.AsyncApi; -using Neuroglia.Serialization; -using StreetLightsApi.Server.Messages; -using System.Text; - namespace StreetLightsApi.Server.Services; [AsyncApi("Movement Sensor API", "1.0.0", Description = "The Movement Sensor API allows you to get remotely notified about movements captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] public class MovementSensorService(ILogger logger, IJsonSerializer serializer) - : BackgroundService + : BackgroundService { + protected ILogger Logger { get; } = logger; protected IJsonSerializer Serializer { get; } = serializer; diff --git a/samples/StreetLightsApi/Services/StreetLightsService.cs b/samples/StreetLightsApi/Services/StreetLightsService.cs index 230d4be..e505d77 100644 --- a/samples/StreetLightsApi/Services/StreetLightsService.cs +++ b/samples/StreetLightsApi/Services/StreetLightsService.cs @@ -11,13 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using StreetLightsApi.Server.Messages; -using Neuroglia.Serialization; -using System.Text; -using Neuroglia.AsyncApi; -using MQTTnet; -using MQTTnet.Client; - namespace StreetLightsApi.Server.Services; [AsyncApi("Streetlights API", "1.0.0", Description = "The Smartylighting Streetlights API allows you to remotely manage the city lights.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] diff --git a/samples/StreetLightsApi/Services/TemperatureSensorServiceV1.cs b/samples/StreetLightsApi/Services/TemperatureSensorServiceV1.cs index cd30c59..44d1ef0 100644 --- a/samples/StreetLightsApi/Services/TemperatureSensorServiceV1.cs +++ b/samples/StreetLightsApi/Services/TemperatureSensorServiceV1.cs @@ -11,16 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -using MQTTnet; -using MQTTnet.Client; -using Neuroglia.AsyncApi; -using Neuroglia.Serialization; -using System.ComponentModel.DataAnnotations; -using System.Text; - namespace StreetLightsApi.Server.Services; - [AsyncApi("Temperature Sensor API", "1.0.0", Description = "The Temperature Sensor API allows you to get remotely notified about temperature changes captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] public class TemperatureSensorServiceV1(ILogger logger, IJsonSerializer serializer) : BackgroundService diff --git a/samples/StreetLightsApi/Services/TemperatureSensorServiceV2.cs b/samples/StreetLightsApi/Services/TemperatureSensorServiceV2.cs index ab44ed6..90d0544 100644 --- a/samples/StreetLightsApi/Services/TemperatureSensorServiceV2.cs +++ b/samples/StreetLightsApi/Services/TemperatureSensorServiceV2.cs @@ -11,13 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using MQTTnet; -using MQTTnet.Client; -using Neuroglia.AsyncApi; -using Neuroglia.Serialization; -using System.ComponentModel.DataAnnotations; -using System.Text; - namespace StreetLightsApi.Server.Services; [AsyncApi("Temperature Sensor API", "2.0.0", Description = "The Temperature Sensor API allows you to get remotely notified about temperature changes captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] @@ -46,7 +39,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await this.MqttClient.SubscribeAsync("OnTemperatureChanged", cancellationToken: stoppingToken).ConfigureAwait(false); } - [Tag("temperature", "A tag for temeprature-related operations"), Tag("sensor", "A tag for sensor-related operations")] + [Tag("temperature", "A tag for temperature-related operations"), Tag("sensor", "A tag for sensor-related operations")] [Channel("temperature/changed"), SubscribeOperation(OperationId = "OnTemperatureChanged", Summary = "Inform about temperature changes captured by sensors")] protected async Task OnTemperatureChanged([Range(-100,100)]decimal degrees, DateTime timestamp) { diff --git a/samples/StreetLightsApi/Usings.cs b/samples/StreetLightsApi/Usings.cs new file mode 100644 index 0000000..925dadd --- /dev/null +++ b/samples/StreetLightsApi/Usings.cs @@ -0,0 +1,26 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +global using Json.Schema; +global using MQTTnet; +global using MQTTnet.Client; +global using Neuroglia.AsyncApi; +global using Neuroglia.AsyncApi.Bindings.Http; +global using Neuroglia.Data.Schemas.Json; +global using Neuroglia.Serialization; +global using StreetLightsApi.Server.Messages; +global using StreetLightsApi.Server.Services; +global using System.ComponentModel; +global using System.ComponentModel.DataAnnotations; +global using System.Net.Mime; +global using System.Text; diff --git a/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQChannelBindingDefinition.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQChannelBindingDefinition.cs index 729d85d..bb56e99 100644 --- a/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQChannelBindingDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IbmMQ/IbmMQChannelBindingDefinition.cs @@ -11,9 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.Bindings; -using Neuroglia.AsyncApi.v2.Bindings.Solace; - namespace Neuroglia.AsyncApi.Bindings.IbmMQ; /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Usings.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Usings.cs index b211bb8..850f2cf 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Usings.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Usings.cs @@ -16,5 +16,4 @@ global using Json.Schema.Generation; global using Microsoft.Extensions.DependencyInjection; global using Neuroglia.AsyncApi.v2; -global using Neuroglia.AsyncApi.v2.Bindings; global using SemVersion; diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/CloudEvents/CloudEventExtensionsTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/CloudEvents/CloudEventExtensionsTests.cs index 8e180db..5940b3c 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/CloudEvents/CloudEventExtensionsTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/CloudEvents/CloudEventExtensionsTests.cs @@ -11,15 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Json.More; -using Json.Schema; -using Microsoft.Extensions.DependencyInjection; -using Neuroglia.AsyncApi.CloudEvents; -using Neuroglia.AsyncApi.FluentBuilders; -using Neuroglia.AsyncApi.v2.Bindings.Http; -using Neuroglia.Eventing.CloudEvents; -using Neuroglia.Serialization.Json; -using System.Net.Mime; +using Neuroglia.AsyncApi.Bindings.Http; namespace Neuroglia.AsyncApi.UnitTests.Cases.CloudEvents; diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/AsyncApiDocumentSerializationTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/AsyncApiDocumentSerializationTests.cs index 2c1eec5..d918315 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/AsyncApiDocumentSerializationTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/AsyncApiDocumentSerializationTests.cs @@ -11,10 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; -using Neuroglia.Serialization.Json; -using Neuroglia.Serialization.Yaml; - namespace Neuroglia.AsyncApi.UnitTests.Cases.Core; public class AsyncApiDocumentSerializationTests diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs index 1e2e881..be255ab 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs @@ -11,12 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Json.Schema; -using Json.Schema.Generation; -using Microsoft.Extensions.DependencyInjection; -using Neuroglia.AsyncApi.FluentBuilders; -using Neuroglia.AsyncApi.v2.Bindings.Http; -using System.Net.Mime; +using Neuroglia.AsyncApi.Bindings.Http; namespace Neuroglia.AsyncApi.UnitTests.Cases.Fluent; diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Generation/JsonSchemaExampleGeneratorTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Generation/JsonSchemaExampleGeneratorTests.cs index fc4fe09..be7ebcd 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Generation/JsonSchemaExampleGeneratorTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Generation/JsonSchemaExampleGeneratorTests.cs @@ -11,13 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Json.Schema; -using Json.Schema.Generation; -using Microsoft.Extensions.DependencyInjection; -using Neuroglia.AsyncApi.Generation; -using Neuroglia.Serialization; -using System.Collections; - namespace Neuroglia.AsyncApi.UnitTests.Cases.Generation; public class JsonSchemaExampleGeneratorTests diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs b/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs index f93b9ce..dca0333 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs @@ -12,8 +12,6 @@ // limitations under the License. using Neuroglia.AsyncApi.Bindings.Mqtt; -using Neuroglia.AsyncApi.v2; -using System.Net.Mime; namespace Neuroglia.AsyncApi.UnitTests.Services; diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Usings.cs b/tests/Neuroglia.AsyncApi.UnitTests/Usings.cs index ded6009..3330fea 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Usings.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Usings.cs @@ -12,5 +12,18 @@ // limitations under the License. global using FluentAssertions; +global using Json.Schema; +global using Json.Schema.Generation; +global using Microsoft.Extensions.DependencyInjection; +global using Neuroglia.AsyncApi.CloudEvents; +global using Neuroglia.AsyncApi.FluentBuilders; +global using Neuroglia.AsyncApi.Generation; global using Neuroglia.AsyncApi.UnitTests.Services; +global using Neuroglia.AsyncApi.v2; +global using Neuroglia.Eventing.CloudEvents; +global using Neuroglia.Serialization; +global using Neuroglia.Serialization.Json; +global using Neuroglia.Serialization.Yaml; +global using System.Collections; +global using System.Net.Mime; global using Xunit; From aecd6cd91dea5c2c632b401b15dd418c3a5c75d2 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Tue, 17 Dec 2024 14:20:38 +0100 Subject: [PATCH 05/21] fix(IO): Added support for writing and reading documents written using the Async API v3 Signed-off-by: Charles d'Avernas --- .../IAsyncApiDocument.cs | 32 +++ .../OAuthFlowDefinitionCollection.cs | 10 +- .../v2/V2AsyncApiDocument.cs | 1 + .../v3/V3AsyncApiDocument.cs | 5 +- .../AsyncApiDocumentReader.cs | 47 +++- .../AsyncApiDocumentWriter.cs | 8 +- .../IServiceCollectionExtensions.cs | 41 +++ .../Interfaces/IAsyncApiDocumentReader.cs | 12 +- .../Interfaces/IAsyncApiDocumentWriter.cs | 16 +- src/Neuroglia.AsyncApi.IO/Usings.cs | 17 ++ .../AsyncApiDocumentSerializationTests.cs | 2 +- .../Cases/IO/IOTests.cs | 102 +++++++ .../Neuroglia.AsyncApi.UnitTests.csproj | 1 + .../Services/AsyncApiDocumentFactory.cs | 261 +++++++++++++++++- 14 files changed, 515 insertions(+), 40 deletions(-) create mode 100644 src/Neuroglia.AsyncApi.Core/IAsyncApiDocument.cs create mode 100644 src/Neuroglia.AsyncApi.IO/Extensions/IServiceCollectionExtensions.cs create mode 100644 src/Neuroglia.AsyncApi.IO/Usings.cs create mode 100644 tests/Neuroglia.AsyncApi.UnitTests/Cases/IO/IOTests.cs diff --git a/src/Neuroglia.AsyncApi.Core/IAsyncApiDocument.cs b/src/Neuroglia.AsyncApi.Core/IAsyncApiDocument.cs new file mode 100644 index 0000000..16ff702 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/IAsyncApiDocument.cs @@ -0,0 +1,32 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi; + +/// +/// Defines the fundamentals of an Async API document +/// +public interface IAsyncApiDocument +{ + + /// + /// Gets the the AsyncAPI Specification version being used. It can be used by tooling Specifications and clients to interpret the version. + /// + /// + /// The structure shall be major.minor.patch, where patch versions must be compatible with the existing major.minor tooling. + /// Typically patch versions will be introduced to address errors in the documentation, and tooling should typically be compatible with the corresponding major.minor (1.0.*). + /// Patch versions will correspond to patches of this document. + /// + string AsyncApi { get; } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/OAuthFlowDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/OAuthFlowDefinitionCollection.cs index 6131354..c7023e9 100644 --- a/src/Neuroglia.AsyncApi.Core/OAuthFlowDefinitionCollection.cs +++ b/src/Neuroglia.AsyncApi.Core/OAuthFlowDefinitionCollection.cs @@ -18,7 +18,6 @@ namespace Neuroglia.AsyncApi; /// [DataContract] public record OAuthFlowDefinitionCollection - : IEnumerable> { /// @@ -45,8 +44,11 @@ public record OAuthFlowDefinitionCollection [DataMember(Order = 4, Name = "authorizationCode"), JsonPropertyOrder(4), JsonPropertyName("authorizationCode"), YamlMember(Order = 4, Alias = "authorizationCode")] public virtual OAuthFlowDefinition? AuthorizationCode { get; set; } - /// - public virtual IEnumerator> GetEnumerator() + /// + /// Gets an that contains all defined flows + /// + /// A new that contains all defined flows + public virtual IEnumerable> AsEnumerable() { if (Implicit != null) yield return new(nameof(Implicit), Implicit); if (Password != null) yield return new(nameof(Password), Password); @@ -54,6 +56,4 @@ public virtual IEnumerator> GetEnumera if (AuthorizationCode != null) yield return new(nameof(AuthorizationCode), AuthorizationCode); } - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs b/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs index a58c76e..d78c5a8 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs @@ -18,6 +18,7 @@ namespace Neuroglia.AsyncApi.v2; /// [DataContract] public record V2AsyncApiDocument + : IAsyncApiDocument { /// diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs b/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs index 7195a33..a214f9a 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs @@ -18,6 +18,7 @@ namespace Neuroglia.AsyncApi.v3; /// [DataContract] public record V3AsyncApiDocument + : IAsyncApiDocument { /// @@ -68,13 +69,13 @@ public record V3AsyncApiDocument /// Gets/sets a name/value map of the operations this application MUST implement. /// [Required, MinLength(1)] - [DataMember(Order = 6, Name = "channels"), JsonPropertyOrder(6), JsonPropertyName("channels"), YamlMember(Order = 6, Alias = "channels")] + [DataMember(Order = 7, Name = "operations"), JsonPropertyOrder(7), JsonPropertyName("operations"), YamlMember(Order = 7, Alias = "operations")] public virtual EquatableDictionary Operations { get; set; } = null!; /// /// Gets/sets an element to hold various reusable objects for the specification. Everything that is defined inside this object represents a resource that MAY or MAY NOT be used in the rest of the document and MAY or MAY NOT be used by the implemented Application. /// - [DataMember(Order = 7, Name = "components"), JsonPropertyOrder(7), JsonPropertyName("components"), YamlMember(Order = 7, Alias = "components")] + [DataMember(Order = 8, Name = "components"), JsonPropertyOrder(8), JsonPropertyName("components"), YamlMember(Order = 8, Alias = "components")] public virtual V3ComponentDefinitionCollection? Components { get; set; } /// diff --git a/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentReader.cs b/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentReader.cs index 98a66eb..64f53db 100644 --- a/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentReader.cs +++ b/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentReader.cs @@ -11,8 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; -using Neuroglia.Serialization; +using YamlDotNet.RepresentationModel; namespace Neuroglia.AsyncApi.IO; @@ -25,7 +24,7 @@ namespace Neuroglia.AsyncApi.IO; /// The service used to serialize and deserialize JSON /// The service used to serialize and deserialize YAML public class AsyncApiDocumentReader(IJsonSerializer jsonSerializer, IYamlSerializer yamlSerializer) - : IAsyncApiDocumentReader + : IAsyncApiDocumentReader { /// @@ -39,15 +38,20 @@ public class AsyncApiDocumentReader(IJsonSerializer jsonSerializer, IYamlSeriali protected IYamlSerializer YamlSerializer { get; } = yamlSerializer; /// - public virtual async Task ReadAsync(Stream stream, CancellationToken cancellationToken = default) + public virtual async Task ReadAsync(Stream stream, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(stream); - var offset = stream.Position; - using var reader = new StreamReader (stream); - string input = reader.ReadToEnd(); - stream.Position = offset; - var serializer = this.ResolveDocumentFormat(input) == AsyncApiDocumentFormat.Json ? (ITextSerializer)this.JsonSerializer : this.YamlSerializer; - return serializer is IAsyncSerializer asyncSerializer ? await asyncSerializer.DeserializeAsync(stream, cancellationToken) : serializer.Deserialize(stream); + using var reader = new StreamReader(stream, leaveOpen: true); + var input = await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false); + var format = this.ResolveDocumentFormat(input); + var version = this.ExtractDocumentSpecVersion(input, format); + var serializer = format == AsyncApiDocumentFormat.Json ? (ITextSerializer)this.JsonSerializer : this.YamlSerializer; + return version.Split('.', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[0] switch + { + "2" => serializer.Deserialize(input), + "3" => serializer.Deserialize(input), + _ => throw new NotSupportedException($"The specified Async API version '{version}' is not supported") + }; } /// @@ -57,4 +61,27 @@ public class AsyncApiDocumentReader(IJsonSerializer jsonSerializer, IYamlSeriali /// The of the specified raw protected virtual AsyncApiDocumentFormat ResolveDocumentFormat(string input) => input.TrimStart().StartsWith('{') && input.TrimEnd().EndsWith('}') ? AsyncApiDocumentFormat.Json : AsyncApiDocumentFormat.Yaml; + /// + /// Extracts the specified document's Async API specification version + /// + /// The serialized document to extract the version from + /// The format of the document to extract the version from + /// The specified document's Async API specification version + protected virtual string ExtractDocumentSpecVersion(string input, AsyncApiDocumentFormat format) + { + if (format == AsyncApiDocumentFormat.Json) + { + using var jsonDoc = JsonDocument.Parse(input); + if (jsonDoc.RootElement.TryGetProperty("asyncapi", out var versionElement)) return versionElement.GetString() ?? string.Empty; + } + else + { + var yaml = new YamlStream(); + yaml.Load(new StringReader(input)); + var mapping = (YamlMappingNode)yaml.Documents[0].RootNode; + if (mapping.Children.TryGetValue(new YamlScalarNode("asyncapi"), out var versionNode)) return ((YamlScalarNode)versionNode).Value!; + } + throw new InvalidDataException("The AsyncAPI version property is missing or invalid."); + } + } diff --git a/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentWriter.cs b/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentWriter.cs index 67e131a..886b0b4 100644 --- a/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentWriter.cs +++ b/src/Neuroglia.AsyncApi.IO/AsyncApiDocumentWriter.cs @@ -11,7 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; using Neuroglia.Serialization; namespace Neuroglia.AsyncApi.IO; @@ -39,19 +38,18 @@ public class AsyncApiDocumentWriter(IJsonSerializer jsonSerializer, IYamlSeriali protected IYamlSerializer YamlSerializer { get; } = yamlSerializer; /// - public virtual async Task WriteAsync(V2AsyncApiDocument document, Stream stream, AsyncApiDocumentFormat format = AsyncApiDocumentFormat.Yaml, CancellationToken cancellationToken = default) + public virtual async Task WriteAsync(IAsyncApiDocument document, Stream stream, AsyncApiDocumentFormat format = AsyncApiDocumentFormat.Yaml, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(document); ArgumentNullException.ThrowIfNull(stream); - switch (format) { case AsyncApiDocumentFormat.Json: - if (this.JsonSerializer is IAsyncSerializer asyncJsonSerializer) await asyncJsonSerializer.SerializeAsync(stream, document, typeof(V2AsyncApiDocument), cancellationToken).ConfigureAwait(false); + if (this.JsonSerializer is IAsyncSerializer asyncJsonSerializer) await asyncJsonSerializer.SerializeAsync(stream, document, document.GetType(), cancellationToken).ConfigureAwait(false); else this.JsonSerializer.Serialize(document, stream); break; case AsyncApiDocumentFormat.Yaml: - if (this.YamlSerializer is IAsyncSerializer asyncYamlSerializer) await asyncYamlSerializer.SerializeAsync(stream, document, typeof(V2AsyncApiDocument), cancellationToken).ConfigureAwait(false); + if (this.YamlSerializer is IAsyncSerializer asyncYamlSerializer) await asyncYamlSerializer.SerializeAsync(stream, document, document.GetType(), cancellationToken).ConfigureAwait(false); else this.YamlSerializer.Serialize(document, stream); break; default: diff --git a/src/Neuroglia.AsyncApi.IO/Extensions/IServiceCollectionExtensions.cs b/src/Neuroglia.AsyncApi.IO/Extensions/IServiceCollectionExtensions.cs new file mode 100644 index 0000000..7e75a84 --- /dev/null +++ b/src/Neuroglia.AsyncApi.IO/Extensions/IServiceCollectionExtensions.cs @@ -0,0 +1,41 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; + +namespace Neuroglia.AsyncApi.IO; + +/// +/// Defines extensions for s +/// +public static class IServiceCollectionExtensions +{ + + /// + /// Adds and configures Async API IO services + /// + /// The to configure + /// The lifetime of the services to add and configure + /// The configured + public static IServiceCollection AddAsyncApiIO(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Singleton) + { + services.AddSerialization(); + services.AddJsonSerializer(); + services.AddYamlDotNetSerializer(); + services.TryAdd(new ServiceDescriptor(typeof(IAsyncApiDocumentReader), typeof(AsyncApiDocumentReader), lifetime: lifetime)); + services.TryAdd(new ServiceDescriptor(typeof(IAsyncApiDocumentWriter), typeof(AsyncApiDocumentWriter), lifetime: lifetime)); + return services; + } + +} diff --git a/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentReader.cs b/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentReader.cs index ffe183a..f6138cd 100644 --- a/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentReader.cs +++ b/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentReader.cs @@ -11,22 +11,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.IO; /// -/// Defines the fundamentals of a service used to read s +/// Defines the fundamentals of a service used to read s /// public interface IAsyncApiDocumentReader { /// - /// Reads a from the specified + /// Reads an from the specified /// - /// The to read the from + /// The to read the from /// A - /// A new - Task ReadAsync(Stream stream, CancellationToken cancellationToken = default); + /// A new + Task ReadAsync(Stream stream, CancellationToken cancellationToken = default); } diff --git a/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentWriter.cs b/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentWriter.cs index 16bdcea..da1a3a7 100644 --- a/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentWriter.cs +++ b/src/Neuroglia.AsyncApi.IO/Interfaces/IAsyncApiDocumentWriter.cs @@ -11,24 +11,22 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.IO; /// -/// Defines the fundamentals of a service used to write s +/// Defines the fundamentals of a service used to write s /// public interface IAsyncApiDocumentWriter { /// - /// Writes the specified to a + /// Writes the specified to a /// - /// The to write - /// The to read the from - /// The format of the to read. Defaults to '' + /// The to write + /// The to read the from + /// The format of the to read. Defaults to '' /// A - /// A new - Task WriteAsync(V2AsyncApiDocument document, Stream stream, AsyncApiDocumentFormat format = AsyncApiDocumentFormat.Yaml, CancellationToken cancellationToken = default); + /// A new + Task WriteAsync(IAsyncApiDocument document, Stream stream, AsyncApiDocumentFormat format = AsyncApiDocumentFormat.Yaml, CancellationToken cancellationToken = default); } diff --git a/src/Neuroglia.AsyncApi.IO/Usings.cs b/src/Neuroglia.AsyncApi.IO/Usings.cs new file mode 100644 index 0000000..b7fc460 --- /dev/null +++ b/src/Neuroglia.AsyncApi.IO/Usings.cs @@ -0,0 +1,17 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +global using Neuroglia.AsyncApi.v2; +global using Neuroglia.AsyncApi.v3; +global using Neuroglia.Serialization; +global using System.Text.Json; diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/AsyncApiDocumentSerializationTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/AsyncApiDocumentSerializationTests.cs index d918315..4e6e75b 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/AsyncApiDocumentSerializationTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/AsyncApiDocumentSerializationTests.cs @@ -20,7 +20,7 @@ public class AsyncApiDocumentSerializationTests public void SerializeAndDeserialize_AsyncApiDocument_Should_Work() { //arrange - var document = AsyncApiDocumentFactory.Create(); + var document = AsyncApiDocumentFactory.CreateV2(); //act var json = JsonSerializer.Default.SerializeToText(document); diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/IO/IOTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/IO/IOTests.cs new file mode 100644 index 0000000..74c457b --- /dev/null +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/IO/IOTests.cs @@ -0,0 +1,102 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.IO; + +namespace Neuroglia.AsyncApi.UnitTests.Cases.IO; + +public class IOTests +{ + + public IOTests() + { + var services = new ServiceCollection(); + services.AddAsyncApiIO(); + this.ServiceProvider = services.BuildServiceProvider(); + } + + protected ServiceProvider ServiceProvider { get; } + + protected IAsyncApiDocumentWriter DocumentWriter => this.ServiceProvider.GetRequiredService(); + + protected IAsyncApiDocumentReader DocumentReader => this.ServiceProvider.GetRequiredService(); + + [Fact] + public async Task Write_Then_Read_Json_Document_V2_Should_Work() + { + //arrange + var documentToWrite = AsyncApiDocumentFactory.CreateV2(); + using var stream = new MemoryStream(); + + //act + await this.DocumentWriter.WriteAsync(documentToWrite, stream, AsyncApiDocumentFormat.Json); + await stream.FlushAsync(); + stream.Position = 0; + var readDocument = await this.DocumentReader.ReadAsync(stream); + + //assert + readDocument.Should().BeEquivalentTo(documentToWrite); + } + + [Fact] + public async Task Write_Then_Read_Yaml_Document_V2_Should_Work() + { + //arrange + var documentToWrite = AsyncApiDocumentFactory.CreateV2(); + using var stream = new MemoryStream(); + + //act + await this.DocumentWriter.WriteAsync(documentToWrite, stream, AsyncApiDocumentFormat.Yaml); + await stream.FlushAsync(); + stream.Position = 0; + var readDocument = await this.DocumentReader.ReadAsync(stream); + + //assert + readDocument.Should().BeEquivalentTo(documentToWrite); + } + + [Fact] + public async Task Write_Then_Read_Json_Document_V3_Should_Work() + { + //arrange + var documentToWrite = AsyncApiDocumentFactory.CreateV3(); + using var stream = new MemoryStream(); + + //act + await this.DocumentWriter.WriteAsync(documentToWrite, stream, AsyncApiDocumentFormat.Json); + await stream.FlushAsync(); + stream.Position = 0; + var readDocument = await this.DocumentReader.ReadAsync(stream); + + //assert + readDocument.Should().BeEquivalentTo(documentToWrite); + } + + [Fact] + public async Task Write_Then_Read_Yaml_Document_V3_Should_Work() + { + //arrange + var documentToWrite = AsyncApiDocumentFactory.CreateV3(); + using var stream = new MemoryStream(); + + //act + await this.DocumentWriter.WriteAsync(documentToWrite, stream, AsyncApiDocumentFormat.Yaml); + await stream.FlushAsync(); + stream.Position = 0; + var readDocument = await this.DocumentReader.ReadAsync(stream); + + //assert + readDocument.Should().BeEquivalentTo(documentToWrite); + } + +} diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Neuroglia.AsyncApi.UnitTests.csproj b/tests/Neuroglia.AsyncApi.UnitTests/Neuroglia.AsyncApi.UnitTests.csproj index 90321c7..6f689b2 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Neuroglia.AsyncApi.UnitTests.csproj +++ b/tests/Neuroglia.AsyncApi.UnitTests/Neuroglia.AsyncApi.UnitTests.csproj @@ -27,6 +27,7 @@ + diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs b/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs index dca0333..9e547a9 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs @@ -12,13 +12,14 @@ // limitations under the License. using Neuroglia.AsyncApi.Bindings.Mqtt; +using Neuroglia.AsyncApi.v3; namespace Neuroglia.AsyncApi.UnitTests.Services; internal static class AsyncApiDocumentFactory { - public static V2AsyncApiDocument Create() + public static V2AsyncApiDocument CreateV2() { return new V2AsyncApiDocument() { @@ -153,4 +154,262 @@ public static V2AsyncApiDocument Create() }; } + public static V3AsyncApiDocument CreateV3() + { + return new V3AsyncApiDocument() + { + AsyncApi = AsyncApiSpecVersion.V3, + Id = "fake-document", + Info = new() + { + Title = "Fake Async API", + Description = "Fake Async API description", + Contact = new() + { + Name = "Fake Contact", + Email = "fake@contact.com", + Url = new("https://fake.contact.com") + }, + License = new() + { + Name = "Apache-2.0", + Url = new("https://spdx.org/licenses/Apache-2.0.html") + } + }, + Servers = new() + { + { + "fake-server", + new() + { + Host = "test.mosquitto.org:{port}", + Protocol = AsyncApiProtocol.Mqtt, + Description = "Fake server", + Variables = new() + { + { + "port", + new() + { + Description = "Fake server port description", + Default = "1833", + Enum = + [ + "1833", + "8883" + ] + } + } + }, + Security = + [ + new() + { + Reference = "#/components/securitySchemes/apiKey" + }, + new() + { + Type = SecuritySchemeType.OAuth2, + Description = "Fake OAUTH2 description", + Flows = new() + { + Implicit = new() + { + AuthorizationUrl = new("https://fake.com"), + Scopes = new() + { + { + "streetlights:on", + "Ability to switch lights on" + }, + { + "streetlights:off", + "Ability to switch lights off" + } + } + } + } + } + ], + Tags = + [ + new() + { + Name = "fake", + Description = "Fake server tag" + } + ] + } + } + }, + Channels = new() + { + { + "fake-channel", + new() + { + Address = "smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured", + Messages = new() + { + { + "lightMeasured", + new() + { + Reference = "#/components/messages/lightMeasured" + } + } + }, + Description = "Fake channel description", + Parameters = new() + { + { + "streetlightId", + new() + { + Reference = "#/components/parameters/streetlightId" + } + } + } + } + } + }, + Operations = new() + { + { + "fake-operation", + new() + { + Action = V3OperationAction.Receive, + Channel = new() + { + Reference = "#/channels/lightingMeasured" + }, + Summary = "Fake operation summary", + Traits = + [ + new() + { + Reference = "#/components/operationTraits/mqtt" + } + ], + Messages = + [ + new() + { + Reference = "#/channels/lightingMeasured/messages/lightMeasured" + } + ] + } + } + }, + Components = new() + { + Messages = new() + { + { + "lightMeasured", + new() + { + Name = "Fake message name", + Title = "Fake message title", + Summary = "Fake message summary", + ContentType = MediaTypeNames.Application.Json, + Traits = + [ + new() + { + Reference = "#/components/messageTraits/commonHeaders" + } + ], + Payload = new() + { + Reference = "#/components/schemas/lightMeasuredPayload" + } + } + } + }, + Parameters = new() + { + { + "streetlightId", + new() + { + Description = "Fake parameter description" + } + } + }, + Schemas = new() + { + { + "lightMeasuredPayload", + new() + { + SchemaFormat = "JsonSchema", + Schema = new + { + Type = "object", + Properties = new + { + Lumens = new + { + Type = "integer", + Minimum = 0 + }.ToExpandoObject()! + }.ToExpandoObject()! + }.ToExpandoObject()! + } + } + }, + MessageTraits = new() + { + { + "commonHeaders", + new() + { + Headers = new() + { + SchemaFormat = "JsonSchema", + Schema = new + { + Type = "object", + Properties = new + { + FakeHeader = new + { + Type = "integer", + Minimum = 0, + Maximum = 10 + }.ToExpandoObject()! + }.ToExpandoObject()! + }.ToExpandoObject()! + } + } + } + }, + OperationTraits = new() + { + { + "mqtt", + new() + { + Title = "Fake operation trait title" + } + } + }, + SecuritySchemes = new() + { + { + "apiKey", + new() + { + Type = SecuritySchemeType.ApiKey, + In = ApiKeyLocation.User, + Description = "Fake ApiKey description" + } + } + } + } + }; + } + } From 817f64d83b45cea81b2307f5355f666537ea9d16 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Tue, 17 Dec 2024 18:13:30 +0100 Subject: [PATCH 06/21] feat(FluentBuilders): Added fluent builders for V3 components Signed-off-by: Charles d'Avernas --- .../CloudEventMessageDefinitionBuilder.cs | 10 +- .../Extensions/IChannelBuilderExtensions.cs | 10 +- src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs | 6 + .../v3/V3AsyncApiDocument.cs | 4 +- .../v3/V3ChannelDefinition.cs | 2 +- .../v3/V3OperationReplyAddressDefinition.cs | 1 + .../v3/V3SchemaDefinition.cs | 2 +- .../IServiceCollectionExtensions.cs | 17 +- .../AsyncApiDocumentBuilder.cs | 345 ----------- .../CorrelationIdDefinitionBuilder.cs | 70 +++ .../ExternalDocumentationDefinitionBuilder.cs | 70 +++ .../ICorrelationIdDefinitionBuilder.cs | 43 ++ ...IExternalDocumentationDefinitionBuilder.cs | 43 ++ .../IOAuthFlowDefinitionCollectionBuilder.cs | 14 + ...eferenceableComponentDefinitionBuilder.cs} | 17 +- ...cs => IServerVariableDefinitionBuilder.cs} | 18 +- .../Interfaces/ITagDefinitionBuilder.cs | 1 + .../OAuthFlowDefinitionBuilder.cs | 18 +- .../OAuthFlowDefinitionCollectionBuilder.cs | 28 +- .../OperationTraitBuilder.cs | 29 - .../ParameterDefinitionBuilder.cs | 27 +- .../RuntimeExpressionBuilder.cs | 2 - ....cs => ServerVariableDefinitionBuilder.cs} | 30 +- .../TagDefinitionBuilder.cs | 17 +- .../Usings.cs | 2 + .../Interfaces/IV2AsyncApiDocumentBuilder.cs} | 124 ++-- .../IV2ChannelDefinitionBuilder.cs} | 31 +- .../IV2MessageDefinitionBuilder.cs} | 30 +- .../IV2MessageTraitDefinitionBuilder.cs} | 45 +- .../IV2OperationDefinitionBuilder.cs} | 20 +- .../IV2OperationTraitDefinitionBuilder.cs} | 27 +- .../IV2ParameterDefinitionBuilder.cs} | 26 +- .../IV2SecuritySchemeDefinitionBuilder.cs} | 36 +- .../Interfaces/IV2ServerDefinitionBuilder.cs} | 30 +- .../v2/V2AsyncApiDocumentBuilder.cs | 343 +++++++++++ .../V2ChannelDefinitionBuilder.cs} | 47 +- .../V2MessageDefinitionBuilder.cs} | 38 +- .../V2MessageTraitDefinitionBuilder.cs} | 74 ++- .../V2OperationDefinitionBuilder.cs} | 30 +- .../V2OperationTraitDefinitionBuilder.cs} | 58 +- .../V2SecuritySchemeDefinitionBuilder.cs} | 56 +- .../V2ServerDefinitionBuilder.cs} | 51 +- .../Interfaces/IV3AsyncApiDocumentBuilder.cs | 284 +++++++++ .../Interfaces/IV3ChannelDefinitionBuilder.cs | 101 ++++ .../Interfaces/IV3MessageDefinitionBuilder.cs | 37 ++ .../IV3MessageExampleDefinitionBuilder.cs | 64 ++ .../IV3MessageTraitDefinitionBuilder.cs | 121 ++++ .../IV3OperationDefinitionBuilder.cs | 64 ++ ...3OperationReplyAddressDefinitionBuilder.cs | 43 ++ .../IV3OperationReplyDefinitionBuilder.cs | 50 ++ .../IV3OperationTraitDefinitionBuilder.cs | 93 +++ .../IV3ParameterDefinitionBuilder.cs | 64 ++ .../Interfaces/IV3SchemaDefinitionBuilder.cs | 43 ++ .../IV3SecuritySchemeDefinitionBuilder.cs | 92 +++ .../Interfaces/IV3ServerDefinitionBuilder.cs | 108 ++++ .../v3/V3ChannelDefinitionBuilder.cs | 569 ++++++++++++++++++ .../v3/V3MessageDefinitionBuilder.cs | 46 ++ .../v3/V3MessageExampleDefinitionBuilder.cs | 86 +++ .../v3/V3MessageTraitDefinitionBuilder.cs | 166 +++++ .../v3/V3OperationDefinitionBuilder.cs | 76 +++ ...3OperationReplyAddressDefinitionBuilder.cs | 70 +++ .../v3/V3OperationReplyDefinitionBuilder.cs | 88 +++ .../v3/V3OperationTraitDefinitionBuilder.cs | 135 +++++ .../v3/V3ParameterDefinitionBuilder.cs | 93 +++ .../v3/V3SchemaDefinitionBuilder.cs | 71 +++ .../v3/V3SecuritySchemeDefinitionBuilder.cs | 135 +++++ .../v3/V3ServerDefinitionBuilder.cs | 151 +++++ .../AsyncApiDocumentGenerationOptions.cs | 3 +- .../AsyncApiDocumentGenerator.cs | 11 +- .../AsyncApiGenerationOptions.cs | 3 +- .../AsyncApiGenerationOptionsBuilder.cs | 4 +- .../IAsyncApiGenerationOptionsBuilder.cs | 5 +- .../CloudEvents/CloudEventExtensionsTests.cs | 6 +- .../Cases/Fluent/FluentBuilderTests.cs | 187 +++++- tests/Neuroglia.AsyncApi.UnitTests/Usings.cs | 1 - 75 files changed, 4114 insertions(+), 848 deletions(-) delete mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/AsyncApiDocumentBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/CorrelationIdDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/ExternalDocumentationDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ICorrelationIdDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IExternalDocumentationDefinitionBuilder.cs rename src/Neuroglia.AsyncApi.FluentBuilders/{MessageTraitBuilder.cs => Interfaces/IReferenceableComponentDefinitionBuilder.cs} (50%) rename src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/{IVariableDefinitionBuilder.cs => IServerVariableDefinitionBuilder.cs} (73%) delete mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitBuilder.cs rename src/Neuroglia.AsyncApi.FluentBuilders/{VariableDefinitionBuilder.cs => ServerVariableDefinitionBuilder.cs} (62%) rename src/Neuroglia.AsyncApi.FluentBuilders/{Interfaces/IAsyncApiDocumentBuilder.cs => v2/Interfaces/IV2AsyncApiDocumentBuilder.cs} (63%) rename src/Neuroglia.AsyncApi.FluentBuilders/{Interfaces/IChannelDefinitionBuilder.cs => v2/Interfaces/IV2ChannelDefinitionBuilder.cs} (68%) rename src/Neuroglia.AsyncApi.FluentBuilders/{Interfaces/IMessageDefinitionBuilder.cs => v2/Interfaces/IV2MessageDefinitionBuilder.cs} (67%) rename src/Neuroglia.AsyncApi.FluentBuilders/{Interfaces/IMessageTraitDefinitionBuilder.cs => v2/Interfaces/IV2MessageTraitDefinitionBuilder.cs} (73%) rename src/Neuroglia.AsyncApi.FluentBuilders/{Interfaces/IOperationDefinitionBuilder.cs => v2/Interfaces/IV2OperationDefinitionBuilder.cs} (69%) rename src/Neuroglia.AsyncApi.FluentBuilders/{Interfaces/IOperationTraitDefinitionBuilder.cs => v2/Interfaces/IV2OperationTraitDefinitionBuilder.cs} (72%) rename src/Neuroglia.AsyncApi.FluentBuilders/{Interfaces/IParameterDefinitionBuilder.cs => v2/Interfaces/IV2ParameterDefinitionBuilder.cs} (71%) rename src/Neuroglia.AsyncApi.FluentBuilders/{Interfaces/ISecuritySchemeDefinitionBuilder.cs => v2/Interfaces/IV2SecuritySchemeDefinitionBuilder.cs} (67%) rename src/Neuroglia.AsyncApi.FluentBuilders/{Interfaces/IServerDefinitionBuilder.cs => v2/Interfaces/IV2ServerDefinitionBuilder.cs} (70%) create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v2/V2AsyncApiDocumentBuilder.cs rename src/Neuroglia.AsyncApi.FluentBuilders/{ChannelDefinitionBuilder.cs => v2/V2ChannelDefinitionBuilder.cs} (59%) rename src/Neuroglia.AsyncApi.FluentBuilders/{MessageDefinitionBuilder.cs => v2/V2MessageDefinitionBuilder.cs} (50%) rename src/Neuroglia.AsyncApi.FluentBuilders/{MessageTraitDefinitionBuilder.cs => v2/V2MessageTraitDefinitionBuilder.cs} (63%) rename src/Neuroglia.AsyncApi.FluentBuilders/{OperationDefinitionBuilder.cs => v2/V2OperationDefinitionBuilder.cs} (55%) rename src/Neuroglia.AsyncApi.FluentBuilders/{OperationTraitDefinitionBuilder.cs => v2/V2OperationTraitDefinitionBuilder.cs} (58%) rename src/Neuroglia.AsyncApi.FluentBuilders/{SecuritySchemeDefinitionBuilder.cs => v2/V2SecuritySchemeDefinitionBuilder.cs} (58%) rename src/Neuroglia.AsyncApi.FluentBuilders/{ServerDefinitionBuilder.cs => v2/V2ServerDefinitionBuilder.cs} (59%) create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3AsyncApiDocumentBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageExampleDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageTraitDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationReplyAddressDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationReplyDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationTraitDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ParameterDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3SchemaDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3SecuritySchemeDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageExampleDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageTraitDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationReplyAddressDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationReplyDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationTraitDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ParameterDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SchemaDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SecuritySchemeDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerDefinitionBuilder.cs diff --git a/src/Neuroglia.AsyncApi.CloudEvents/Extensions/CloudEventMessageDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.CloudEvents/Extensions/CloudEventMessageDefinitionBuilder.cs index ea69f1e..63062b4 100644 --- a/src/Neuroglia.AsyncApi.CloudEvents/Extensions/CloudEventMessageDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.CloudEvents/Extensions/CloudEventMessageDefinitionBuilder.cs @@ -13,18 +13,18 @@ using Json.Schema; using Json.Schema.Generation; -using Neuroglia.AsyncApi.FluentBuilders; using Neuroglia.AsyncApi.v2; using Neuroglia.Eventing.CloudEvents; using Neuroglia.Data.Schemas.Json; +using Neuroglia.AsyncApi.FluentBuilders.v2; namespace Neuroglia.AsyncApi.CloudEvents; /// /// Represents the default implementation of the interface /// -/// The underlying wrapped by the -public class CloudEventMessageDefinitionBuilder(IMessageDefinitionBuilder underlyingBuilder) +/// The underlying wrapped by the +public class CloudEventMessageDefinitionBuilder(IV2MessageDefinitionBuilder underlyingBuilder) : ICloudEventMessageDefinitionBuilder { @@ -36,9 +36,9 @@ public class CloudEventMessageDefinitionBuilder(IMessageDefinitionBuilder underl static readonly JsonSchema DefaultSchema = new JsonSchemaBuilder().FromType(); /// - /// Gets the underlying wrapped by the + /// Gets the underlying wrapped by the /// - protected IMessageDefinitionBuilder UnderlyingBuilder { get; } = underlyingBuilder; + protected IV2MessageDefinitionBuilder UnderlyingBuilder { get; } = underlyingBuilder; /// /// Gets a name/ mapping of all context attributes that have been explicitly set diff --git a/src/Neuroglia.AsyncApi.CloudEvents/Extensions/IChannelBuilderExtensions.cs b/src/Neuroglia.AsyncApi.CloudEvents/Extensions/IChannelBuilderExtensions.cs index 04af4ca..5833723 100644 --- a/src/Neuroglia.AsyncApi.CloudEvents/Extensions/IChannelBuilderExtensions.cs +++ b/src/Neuroglia.AsyncApi.CloudEvents/Extensions/IChannelBuilderExtensions.cs @@ -11,13 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.FluentBuilders; +using Neuroglia.AsyncApi.FluentBuilders.v2; using Neuroglia.AsyncApi.v2; namespace Neuroglia.AsyncApi.CloudEvents; /// -/// Defines extensions for s +/// Defines extensions for s /// public static class IAsyncApiDocumentBuilderExtensions { @@ -25,10 +25,10 @@ public static class IAsyncApiDocumentBuilderExtensions /// /// Configures the to build to use the specified /// - /// The to configure + /// The to configure /// An used to setup the to use - /// The configured - public static IOperationDefinitionBuilder WithCloudEventMessage(this IOperationDefinitionBuilder operation, Action setup) + /// The configured + public static IV2OperationDefinitionBuilder WithCloudEventMessage(this IV2OperationDefinitionBuilder operation, Action setup) { ArgumentNullException.ThrowIfNull(operation); ArgumentNullException.ThrowIfNull(setup); diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs index 044ae7e..412090f 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs @@ -64,6 +64,12 @@ public record V3ApiInfo [DataMember(Order = 7, Name = "tags"), JsonPropertyOrder(7), JsonPropertyName("tags"), YamlMember(Order = 7, Alias = "tags")] public virtual EquatableList? Tags { get; set; } + /// + /// Gets/sets additional external documentation of the exposed API. + /// + [DataMember(Order = 8, Name = "externalDocs"), JsonPropertyOrder(8), JsonPropertyName("externalDocs"), YamlMember(Order = 8, Alias = "externalDocs")] + public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + /// public override string ToString() => this.Title; diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs b/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs index a214f9a..8940877 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs @@ -11,6 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System.Net.Mime; + namespace Neuroglia.AsyncApi.v3; /// @@ -56,7 +58,7 @@ public record V3AsyncApiDocument /// Gets/sets the default content type to use when encoding/decoding a message's payload. /// [DataMember(Order = 5, Name = "defaultContentType"), JsonPropertyOrder(5), JsonPropertyName("defaultContentType"), YamlMember(Order = 5, Alias = "defaultContentType")] - public virtual string? DefaultContentType { get; set; } + public virtual string DefaultContentType { get; set; } = MediaTypeNames.Application.Json; /// /// Gets/sets a collection containing the available channels and messages for the API. diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs index cdc240a..0641cd0 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs @@ -34,7 +34,7 @@ public record V3ChannelDefinition /// Gets/sets a map of the messages that will be sent to this channel by any application at any time. Every message sent to this channel MUST be valid against one, and only one, of the message objects defined in this map. /// [DataMember(Order = 2, Name = "messages"), JsonPropertyOrder(2), JsonPropertyName("messages"), YamlMember(Order = 2, Alias = "messages", ScalarStyle = ScalarStyle.SingleQuoted)] - public virtual EquatableDictionary? Messages { get; set; } + public virtual EquatableDictionary? Messages { get; set; } /// /// Gets/sets a human-friendly title for the channel. diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3OperationReplyAddressDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3OperationReplyAddressDefinition.cs index b56ca37..708af5b 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3OperationReplyAddressDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3OperationReplyAddressDefinition.cs @@ -30,6 +30,7 @@ public record V3OperationReplyAddressDefinition /// /// Gets/sets a runtime expression that specifies the location of the reply address. /// + [Required] [DataMember(Order = 2, Name = "location"), JsonPropertyOrder(2), JsonPropertyName("location"), YamlMember(Order = 2, Alias = "location", ScalarStyle = ScalarStyle.SingleQuoted)] public virtual string Location { get; set; } = null!; diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3SchemaDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3SchemaDefinition.cs index a28624d..d3322dc 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3SchemaDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3SchemaDefinition.cs @@ -26,7 +26,7 @@ public record V3SchemaDefinition /// If schemaFormat is missing, it MUST default to application/vnd.aai.asyncapi+json;version={{asyncapi}} where {{asyncapi}} matches the AsyncAPI Version String. In such a case, this would make the Multi Format Schema Object equivalent to the Schema Object. When using Reference Object within the schema, the schemaFormat of the resource being referenced MUST match the schemaFormat of the schema that contains the initial reference. /// [DataMember(Order = 1, Name = "schemaFormat"), JsonPropertyOrder(1), JsonPropertyName("schemaFormat"), YamlMember(Order = 1, Alias = "schemaFormat")] - public virtual string? SchemaFormat { get; set; } + public virtual string? SchemaFormat { get; set; } = $"application/vnd.aai.asyncapi+json;version={AsyncApiSpecVersion.V3}"; /// /// Gets/sets the definition of the message payload. diff --git a/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/IServiceCollectionExtensions.cs b/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/IServiceCollectionExtensions.cs index d99f582..b07ee43 100644 --- a/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/IServiceCollectionExtensions.cs +++ b/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/IServiceCollectionExtensions.cs @@ -15,7 +15,8 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; -using Neuroglia.AsyncApi.FluentBuilders; +using Neuroglia.AsyncApi.FluentBuilders.v2; +using Neuroglia.AsyncApi.FluentBuilders.v2; using Neuroglia.AsyncApi.Generation; using Neuroglia.AsyncApi.IO; using Neuroglia.AsyncApi.v2; @@ -42,7 +43,7 @@ public static IServiceCollection AddAsyncApi(this IServiceCollection services) services.AddYamlDotNetSerializer(); services.TryAddSingleton(); services.TryAddSingleton(); - services.TryAddTransient(); + services.TryAddTransient(); services.AddValidatorsFromAssemblyContaining(ServiceLifetime.Transient); return services; } @@ -89,13 +90,13 @@ public static IServiceCollection AddAsyncApiDocument(this IServiceCollection ser /// Adds and configures a new /// /// The to configure - /// An used to setup the used to build the to add + /// An used to setup the used to build the to add /// The configured - public static IServiceCollection AddAsyncApiDocument(this IServiceCollection services, Action setup) + public static IServiceCollection AddAsyncApiDocument(this IServiceCollection services, Action setup) { services.AddSingleton(provider => { - var builder = provider.GetRequiredService(); + var builder = provider.GetRequiredService(); setup(provider, builder); return builder.Build(); }); @@ -107,13 +108,13 @@ public static IServiceCollection AddAsyncApiDocument(this IServiceCollection ser /// Adds and configures a new /// /// The to configure - /// An used to setup the used to build the to add + /// An used to setup the used to build the to add /// The configured - public static IServiceCollection AddAsyncApiDocument(this IServiceCollection services, Action setup) + public static IServiceCollection AddAsyncApiDocument(this IServiceCollection services, Action setup) { services.AddSingleton(provider => { - var builder = provider.GetRequiredService(); + var builder = provider.GetRequiredService(); setup(builder); return builder.Build(); }); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/AsyncApiDocumentBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/AsyncApiDocumentBuilder.cs deleted file mode 100644 index fab8387..0000000 --- a/src/Neuroglia.AsyncApi.FluentBuilders/AsyncApiDocumentBuilder.cs +++ /dev/null @@ -1,345 +0,0 @@ -// Copyright © 2021-Present Neuroglia SRL. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"), -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using Neuroglia.AsyncApi.Bindings; - -namespace Neuroglia.AsyncApi.FluentBuilders; - -/// -/// Represents the default implementation of the -/// -/// -/// Initializes a new -/// -/// The current -/// The services used to validate s -public class AsyncApiDocumentBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : IAsyncApiDocumentBuilder -{ - - /// - /// Gets the current - /// - protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; - - /// - /// Gets the services used to validate s - /// - protected virtual IEnumerable> Validators { get; } = validators; - - /// - /// Gets the to configure - /// - protected virtual V2AsyncApiDocument Document { get; } = new(); - - /// - public virtual IAsyncApiDocumentBuilder WithSpecVersion(string version) - { - if (string.IsNullOrWhiteSpace(version)) throw new ArgumentNullException(nameof(version)); - if (!SemanticVersion.TryParse(version, out _)) throw new ArgumentException($"The specified value '{version}' is not a valid semantic version", nameof(version)); - this.Document.AsyncApi = version; - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithId(string id) - { - this.Document.Id = id; - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithTitle(string title) - { - if (string.IsNullOrWhiteSpace(title)) throw new ArgumentNullException(nameof(title)); - this.Document.Info ??= new(); - this.Document.Info.Title = title; - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithVersion(string version) - { - if (string.IsNullOrWhiteSpace(version)) throw new ArgumentNullException(nameof(version)); - if (!SemanticVersion.TryParse(version, out _)) throw new ArgumentException($"The specified value '{version}' is not a valid semantic version", nameof(version)); - if (this.Document.Info == null)this.Document.Info = new(); - this.Document.Info.Version = version; - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithDescription(string? description) - { - if (this.Document.Info == null) this.Document.Info = new(); - this.Document.Info.Description = description; - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithTermsOfService(Uri uri) - { - if (this.Document.Info == null) this.Document.Info = new(); - this.Document.Info.TermsOfService = uri; - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithContact(string name, Uri? uri = null, string? email = null) - { - if (this.Document.Info == null) this.Document.Info = new(); - this.Document.Info.Contact = new() { Name = name, Url = uri, Email = email }; - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithLicense(string name, Uri? uri = null) - { - if (this.Document.Info == null) this.Document.Info = new(); - this.Document.Info.License = new() { Name = name, Url = uri }; - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithDefaultContentType(string contentType) - { - this.Document.DefaultContentType = contentType; - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithTag(Action setup) - { - ArgumentNullException.ThrowIfNull(setup); - this.Document.Tags ??= []; - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - this.Document.Tags.Add(builder.Build()); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithExternalDocumentation(Uri uri, string? description = null) - { - ArgumentNullException.ThrowIfNull(uri); - this.Document.ExternalDocs = new() { Url = uri, Description = description }; - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithServer(string name, Action setup) - { - if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(setup); - if (this.Document.Servers == null) this.Document.Servers = []; - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - this.Document.Servers.Add(name, builder.Build()); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithChannel(string name, Action setup) - { - if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(setup); - this.Document.Channels ??= []; - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - this.Document.Channels.Add(name, builder.Build()); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithSecurityScheme(string name, V2SecuritySchemeDefinition scheme) - { - if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(scheme); - if (this.Document.Components == null) this.Document.Components = new(); - if (this.Document.Components.SecuritySchemes == null) this.Document.Components.SecuritySchemes = []; - this.Document.Components.SecuritySchemes.Add(name, scheme); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithSecurityScheme(string name, Action setup) - { - if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(setup); - this.Document.Components ??= new(); - this.Document.Components.SecuritySchemes ??= []; - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - this.Document.Components.SecuritySchemes.Add(name, builder.Build()); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithSchemaComponent(string name, JsonSchema schema) - { - if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(schema); - if (this.Document.Components == null) this.Document.Components = new(); - if (this.Document.Components.Schemas == null) this.Document.Components.Schemas = []; - this.Document.Components.Schemas.Add(name, schema); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithMessageComponent(string name, V2MessageDefinition message) - { - if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(message); - if (this.Document.Components == null) this.Document.Components = new(); - if (this.Document.Components.Messages == null)this.Document.Components.Messages = []; - this.Document.Components.Messages.Add(name, message); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithMessageComponent(string name, Action setup) - { - if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - return this.WithMessageComponent(name, builder.Build()); - } - - /// - public virtual IAsyncApiDocumentBuilder WithParameterComponent(string name, V2ParameterDefinition parameter) - { - if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(parameter); - if (this.Document.Components == null)this.Document.Components = new(); - if (this.Document.Components.Parameters == null)this.Document.Components.Parameters = []; - this.Document.Components.Parameters.Add(name, parameter); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithParameterComponent(string name, Action setup) - { - if (string.IsNullOrWhiteSpace(name)) - throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - return this.WithParameterComponent(name, builder.Build()); - } - - /// - public virtual IAsyncApiDocumentBuilder WithCorrelationIdComponent(string name, CorrelationIdDefinition correlationId) - { - if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(correlationId); - if (this.Document.Components == null)this.Document.Components = new(); - if (this.Document.Components.CorrelationIds == null)this.Document.Components.CorrelationIds = []; - this.Document.Components.CorrelationIds.Add(name, correlationId); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithOperationTraitComponent(string name, V2OperationTraitDefinition trait) - { - if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(trait); - if (this.Document.Components == null)this.Document.Components = new(); - if (this.Document.Components.OperationTraits == null)this.Document.Components.OperationTraits = []; - this.Document.Components.OperationTraits.Add(name, trait); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithOperationTraitComponent(string name, Action setup) - { - if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - return this.WithOperationTraitComponent(name, builder.Build()); - } - - /// - public virtual IAsyncApiDocumentBuilder WithMessageTraitComponent(string name, V2MessageTraitDefinition trait) - { - if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(trait); - if (this.Document.Components == null) this.Document.Components = new(); - if (this.Document.Components.MessageTraits == null)this.Document.Components.MessageTraits = []; - this.Document.Components.MessageTraits.Add(name, trait); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithMessageTraitComponent(string name, Action setup) - { - if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - return this.WithMessageTraitComponent(name, builder.Build()); - } - - /// - public virtual IAsyncApiDocumentBuilder WithServerBindingComponent(string name, ServerBindingDefinitionCollection bindings) - { - if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(bindings); - if (this.Document.Components == null)this.Document.Components = new(); - if (this.Document.Components.ServerBindings == null)this.Document.Components.ServerBindings = []; - this.Document.Components.ServerBindings.Add(name, bindings); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithChannelBindingComponent(string name, ChannelBindingDefinitionCollection bindings) - { - if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(bindings); - if (this.Document.Components == null)this.Document.Components = new(); - if (this.Document.Components.ChannelBindings == null)this.Document.Components.ChannelBindings = []; - this.Document.Components.ChannelBindings.Add(name, bindings); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithOperationBindingComponent(string name, OperationBindingDefinitionCollection bindings) - { - if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(bindings); - if (this.Document.Components == null)this.Document.Components = new(); - if (this.Document.Components.OperationBindings == null)this.Document.Components.OperationBindings = []; - this.Document.Components.OperationBindings.Add(name, bindings); - return this; - } - - /// - public virtual IAsyncApiDocumentBuilder WithMessageBindingComponent(string name, MessageBindingDefinitionCollection bindings) - { - if (string.IsNullOrWhiteSpace(name))throw new ArgumentNullException(nameof(name)); - ArgumentNullException.ThrowIfNull(bindings); - if (this.Document.Components == null) this.Document.Components = new(); - if (this.Document.Components.MessageBindings == null)this.Document.Components.MessageBindings = []; - this.Document.Components.MessageBindings.Add(name, bindings); - return this; - } - - /// - public virtual V2AsyncApiDocument Build() - { - var validationResults = this.Validators.Select(v => v.Validate(this.Document)); - if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); - return this.Document; - } - -} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/CorrelationIdDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/CorrelationIdDefinitionBuilder.cs new file mode 100644 index 0000000..3717911 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/CorrelationIdDefinitionBuilder.cs @@ -0,0 +1,70 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// An containing the services used to validate +public class CorrelationIdDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : ICorrelationIdDefinitionBuilder +{ + + /// + /// Gets the current + /// + protected IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets an containing the services used to validate + /// + protected IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected CorrelationIdDefinition CorrelationId { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + CorrelationId.Reference = reference; + } + + /// + public virtual ICorrelationIdDefinitionBuilder WithLocation(string location) + { + ArgumentException.ThrowIfNullOrWhiteSpace(location); + CorrelationId.Location = location; + return this; + } + + /// + public virtual ICorrelationIdDefinitionBuilder WithDescription(string? description) + { + CorrelationId.Description = description; + return this; + } + + /// + public virtual CorrelationIdDefinition Build() + { + var validationResults = Validators.Select(v => v.Validate(CorrelationId)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); + return CorrelationId; + } + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/ExternalDocumentationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/ExternalDocumentationDefinitionBuilder.cs new file mode 100644 index 0000000..ce8dd67 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/ExternalDocumentationDefinitionBuilder.cs @@ -0,0 +1,70 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// The services used to validate s +public class ExternalDocumentationDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IExternalDocumentationDefinitionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected virtual ExternalDocumentationDefinition ExternalDocumentation { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + ExternalDocumentation.Reference = reference; + } + + /// + public virtual IExternalDocumentationDefinitionBuilder WithUrl(Uri url) + { + ArgumentNullException.ThrowIfNull(url); + ExternalDocumentation.Url = url; + return this; + } + + /// + public virtual IExternalDocumentationDefinitionBuilder WithDescription(string? description) + { + ExternalDocumentation.Description = description; + return this; + } + + /// + public virtual ExternalDocumentationDefinition Build() + { + var validationResults = Validators.Select(v => v.Validate(ExternalDocumentation)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return ExternalDocumentation; + } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ICorrelationIdDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ICorrelationIdDefinitionBuilder.cs new file mode 100644 index 0000000..4189a67 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ICorrelationIdDefinitionBuilder.cs @@ -0,0 +1,43 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface ICorrelationIdDefinitionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to use the specified location expression + /// + /// The location expression to use + /// The configured + ICorrelationIdDefinitionBuilder WithLocation(string location); + + /// + /// Configures the to use the specified description + /// + /// The description to use + /// The configured + ICorrelationIdDefinitionBuilder WithDescription(string? description); + + /// + /// Builds the configured + /// + /// A new + CorrelationIdDefinition Build(); + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IExternalDocumentationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IExternalDocumentationDefinitionBuilder.cs new file mode 100644 index 0000000..e6e5561 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IExternalDocumentationDefinitionBuilder.cs @@ -0,0 +1,43 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IExternalDocumentationDefinitionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to build to use the specified url + /// + /// The url of the to build + /// The configured + IExternalDocumentationDefinitionBuilder WithUrl(Uri url); + + /// + /// Configures the to build to use the specified description + /// + /// The description of the to build + /// The configured + IExternalDocumentationDefinitionBuilder WithDescription(string? description); + + /// + /// Builds the configured + /// + /// A new + ExternalDocumentationDefinition Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOAuthFlowDefinitionCollectionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOAuthFlowDefinitionCollectionBuilder.cs index cb3f006..bbeee11 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOAuthFlowDefinitionCollectionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOAuthFlowDefinitionCollectionBuilder.cs @@ -11,6 +11,20 @@ // See the License for the specific language governing permissions and // limitations under the License. + +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + namespace Neuroglia.AsyncApi.FluentBuilders; /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IReferenceableComponentDefinitionBuilder.cs similarity index 50% rename from src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IReferenceableComponentDefinitionBuilder.cs index 99c715f..fa54d03 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IReferenceableComponentDefinitionBuilder.cs @@ -11,22 +11,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Represents the default implementation of the interface +/// Defines the fundamentals of a service used to build a /// -public class MessageTraitBuilder - : MessageTraitDefinitionBuilder, IMessageTraitBuilder +public interface IReferenceableComponentDefinitionBuilder + where TComponent : ReferenceableComponentDefinition { /// - /// Initializes a new + /// Uses the specified component /// - /// The current - /// An containing the services used to validate s - public MessageTraitBuilder(IServiceProvider serviceProvider, IEnumerable> validators) : base(serviceProvider, validators) { } + /// The reference of the component to use + void Use(string reference); -} +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IVariableDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerVariableDefinitionBuilder.cs similarity index 73% rename from src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IVariableDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerVariableDefinitionBuilder.cs index a2cf3ce..c7a00a0 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IVariableDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerVariableDefinitionBuilder.cs @@ -16,36 +16,36 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// /// Defines the fundamentals of a service used to build s /// -public interface IVariableDefinitionBuilder +public interface IServerVariableDefinitionBuilder { /// /// Configures the to build to use the specified enum values /// /// An array of values to be used if the substitution options are from a limited set. - /// The configured - IVariableDefinitionBuilder WithEnumValues(params string[] values); + /// The configured + IServerVariableDefinitionBuilder WithEnumValues(params string[] values); /// /// Configures the to build to use the specified default value /// /// The value to use by default for substitution, and to send, if an alternate value is not supplied. - /// The configured - IVariableDefinitionBuilder WithDefaultValue(string value); + /// The configured + IServerVariableDefinitionBuilder WithDefaultValue(string value); /// /// Configures the to use the specified description /// /// The description to use - /// The configured - IVariableDefinitionBuilder WithDescription(string? description); + /// The configured + IServerVariableDefinitionBuilder WithDescription(string? description); /// /// Adds the specified example to the to build /// /// The example to add - /// The configured - IVariableDefinitionBuilder WithExample(string example); + /// The configured + IServerVariableDefinitionBuilder WithExample(string example); /// /// Builds a new diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ITagDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ITagDefinitionBuilder.cs index f5f4ac7..188e666 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ITagDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ITagDefinitionBuilder.cs @@ -17,6 +17,7 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// Defines the fundamentals of a service used to build s /// public interface ITagDefinitionBuilder + : IReferenceableComponentDefinitionBuilder { /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionBuilder.cs index d5a162e..b8b748a 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionBuilder.cs @@ -40,21 +40,21 @@ public class OAuthFlowDefinitionBuilder(IServiceProvider serviceProvider, IEnume /// public virtual IOAuthFlowDefinitionBuilder WithAuthorizationUrl(Uri? uri) { - this.Flow.AuthorizationUrl = uri; + Flow.AuthorizationUrl = uri; return this; } /// public virtual IOAuthFlowDefinitionBuilder WithTokenUrl(Uri? uri) { - this.Flow.TokenUrl = uri; + Flow.TokenUrl = uri; return this; } /// public virtual IOAuthFlowDefinitionBuilder WithRefreshUrl(Uri? uri) { - this.Flow.RefreshUrl = uri; + Flow.RefreshUrl = uri; return this; } @@ -62,8 +62,8 @@ public virtual IOAuthFlowDefinitionBuilder WithRefreshUrl(Uri? uri) public virtual IOAuthFlowDefinitionBuilder WithScope(string name, string? description = null) { ArgumentException.ThrowIfNullOrWhiteSpace(name); - this.Flow.Scopes ??= []; - this.Flow.Scopes[name] = description!; + Flow.Scopes ??= []; + Flow.Scopes[name] = description!; return this; } @@ -71,7 +71,7 @@ public virtual IOAuthFlowDefinitionBuilder WithScope(string name, string? descri public virtual IOAuthFlowDefinitionBuilder WithScopes(IDictionary scopes) { ArgumentNullException.ThrowIfNull(scopes); - this.Flow.Scopes = new(scopes); + Flow.Scopes = new(scopes); return this; } @@ -79,16 +79,16 @@ public virtual IOAuthFlowDefinitionBuilder WithScopes(IDictionary[] scopes) { ArgumentNullException.ThrowIfNull(scopes); - this.Flow.Scopes = new(scopes); + Flow.Scopes = new(scopes); return this; } /// public virtual OAuthFlowDefinition Build() { - var validationResults = this.Validators.Select(v => v.Validate(this.Flow)); + var validationResults = Validators.Select(v => v.Validate(Flow)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); - return this.Flow; + return Flow; } } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionCollectionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionCollectionBuilder.cs index ba0d95d..db4bdc7 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionCollectionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/OAuthFlowDefinitionCollectionBuilder.cs @@ -40,69 +40,69 @@ public class OAuthFlowDefinitionCollectionBuilder(IServiceProvider serviceProvid /// public virtual IOAuthFlowDefinitionCollectionBuilder WithAuthorizationCodeFlow(OAuthFlowDefinition? flow) { - this.Flows.AuthorizationCode = flow; + Flows.AuthorizationCode = flow; return this; } /// public virtual IOAuthFlowDefinitionCollectionBuilder WithAuthorizationCodeFlow(Action setup) { - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); - return this.WithAuthorizationCodeFlow(builder.Build()); + return WithAuthorizationCodeFlow(builder.Build()); } /// public virtual IOAuthFlowDefinitionCollectionBuilder WithClientCredentialsFlow(OAuthFlowDefinition? flow) { - this.Flows.ClientCredentials = flow; + Flows.ClientCredentials = flow; return this; } /// public virtual IOAuthFlowDefinitionCollectionBuilder WithClientCredentialsFlow(Action setup) { - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); - return this.WithClientCredentialsFlow(builder.Build()); + return WithClientCredentialsFlow(builder.Build()); } /// public virtual IOAuthFlowDefinitionCollectionBuilder WithImplicitFlow(OAuthFlowDefinition? flow) { - this.Flows.Implicit = flow; + Flows.Implicit = flow; return this; } /// public virtual IOAuthFlowDefinitionCollectionBuilder WithImplicitFlow(Action setup) { - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); - return this.WithImplicitFlow(builder.Build()); + return WithImplicitFlow(builder.Build()); } /// public virtual IOAuthFlowDefinitionCollectionBuilder WithPasswordFlow(OAuthFlowDefinition? flow) { - this.Flows.Password = flow; + Flows.Password = flow; return this; } /// public virtual IOAuthFlowDefinitionCollectionBuilder WithPasswordFlow(Action setup) { - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); - return this.WithPasswordFlow(builder.Build()); + return WithPasswordFlow(builder.Build()); } /// public virtual OAuthFlowDefinitionCollection Build() { - var validationResults = this.Validators.Select(v => v.Validate(this.Flows)); + var validationResults = Validators.Select(v => v.Validate(Flows)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); - return this.Flows; + return Flows; } } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitBuilder.cs deleted file mode 100644 index cfcc229..0000000 --- a/src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitBuilder.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright © 2021-Present Neuroglia SRL. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"), -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi.FluentBuilders; - -/// -/// Represents the base class for all implementations -/// -/// -/// Initializes a new -/// -/// The current -/// An containing the services used to validate s -public class OperationTraitBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : OperationTraitDefinitionBuilder(serviceProvider, validators), IOperationTraitBuilder -{ -} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/ParameterDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/ParameterDefinitionBuilder.cs index a340c17..a64741b 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/ParameterDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/ParameterDefinitionBuilder.cs @@ -11,12 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.FluentBuilders.v2; using Neuroglia.Data.Schemas.Json; namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Represents the default implementation of the interface +/// Represents the default implementation of the interface /// /// /// Initializes a new @@ -24,7 +25,7 @@ namespace Neuroglia.AsyncApi.FluentBuilders; /// The current /// The services used to validate s public class ParameterDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : IParameterDefinitionBuilder + : IV2ParameterDefinitionBuilder { /// @@ -43,43 +44,43 @@ public class ParameterDefinitionBuilder(IServiceProvider serviceProvider, IEnume protected virtual V2ParameterDefinition Parameter { get; } = new(); /// - public virtual IParameterDefinitionBuilder OfType() => this.OfType(typeof(TParameter)); + public virtual IV2ParameterDefinitionBuilder OfType() => OfType(typeof(TParameter)); /// - public virtual IParameterDefinitionBuilder OfType(Type parameterType) + public virtual IV2ParameterDefinitionBuilder OfType(Type parameterType) { ArgumentNullException.ThrowIfNull(parameterType); - return this.WithSchema(new JsonSchemaBuilder().FromType(parameterType, JsonSchemaGeneratorConfiguration.Default)); + return WithSchema(new JsonSchemaBuilder().FromType(parameterType, JsonSchemaGeneratorConfiguration.Default)); } /// - public virtual IParameterDefinitionBuilder WithSchema(JsonSchema schema) + public virtual IV2ParameterDefinitionBuilder WithSchema(JsonSchema schema) { - this.Parameter.Schema = schema ?? throw new ArgumentNullException(nameof(schema)); + Parameter.Schema = schema ?? throw new ArgumentNullException(nameof(schema)); return this; } /// - public virtual IParameterDefinitionBuilder WithDescription(string? description) + public virtual IV2ParameterDefinitionBuilder WithDescription(string? description) { - this.Parameter.Description = description; + Parameter.Description = description; return this; } /// - public virtual IParameterDefinitionBuilder WithLocation(string location) + public virtual IV2ParameterDefinitionBuilder WithLocation(string location) { if (string.IsNullOrWhiteSpace(location)) throw new ArgumentNullException(nameof(location)); - this.Parameter.Location = location; + Parameter.Location = location; return this; } /// public virtual V2ParameterDefinition Build() { - var validationResults = this.Validators.Select(v => v.Validate(this.Parameter)); + var validationResults = Validators.Select(v => v.Validate(Parameter)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); - return this.Parameter; + return Parameter; } } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/RuntimeExpressionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/RuntimeExpressionBuilder.cs index 66e9902..9cb773d 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/RuntimeExpressionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/RuntimeExpressionBuilder.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.FluentBuilders; - namespace Neuroglia.AsyncApi.FluentBuilders; /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/VariableDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/ServerVariableDefinitionBuilder.cs similarity index 62% rename from src/Neuroglia.AsyncApi.FluentBuilders/VariableDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/ServerVariableDefinitionBuilder.cs index f601fd6..2357b17 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/VariableDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/ServerVariableDefinitionBuilder.cs @@ -11,17 +11,19 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.FluentBuilders; + namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Represents the default implementation of the interface +/// Represents the default implementation of the interface /// /// -/// Initializes a new +/// Initializes a new /// /// The services used to validate s -public class VariableDefinitionBuilder(IEnumerable> validators) - : IVariableDefinitionBuilder +public class ServerVariableDefinitionBuilder(IEnumerable> validators) + : IServerVariableDefinitionBuilder { /// @@ -35,36 +37,36 @@ public class VariableDefinitionBuilder(IEnumerable - public virtual IVariableDefinitionBuilder WithEnumValues(params string[] values) + public virtual IServerVariableDefinitionBuilder WithEnumValues(params string[] values) { - this.Variable.Enum = new(values); + Variable.Enum = new(values); return this; } /// - public virtual IVariableDefinitionBuilder WithDefaultValue(string value) + public virtual IServerVariableDefinitionBuilder WithDefaultValue(string value) { - this.Variable.Default = value; + Variable.Default = value; return this; } /// - public virtual IVariableDefinitionBuilder WithDescription(string? description) + public virtual IServerVariableDefinitionBuilder WithDescription(string? description) { - this.Variable.Description = description; + Variable.Description = description; return this; } /// - public virtual IVariableDefinitionBuilder WithExample(string example) + public virtual IServerVariableDefinitionBuilder WithExample(string example) { if (string.IsNullOrWhiteSpace(example)) throw new ArgumentNullException(nameof(example)); - this.Variable.Examples ??= []; - this.Variable.Examples.Add(example); + Variable.Examples ??= []; + Variable.Examples.Add(example); return this; } /// - public virtual ServerVariableDefinition Build() => this.Variable; + public virtual ServerVariableDefinition Build() => Variable; } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/TagDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/TagDefinitionBuilder.cs index accf9e0..296f848 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/TagDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/TagDefinitionBuilder.cs @@ -34,18 +34,25 @@ public class TagDefinitionBuilder(IEnumerable> validat /// protected virtual TagDefinition Tag { get; } = new(); + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + Tag.Reference = reference; + } + /// public virtual ITagDefinitionBuilder WithName(string name) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); - this.Tag.Name = name; + Tag.Name = name; return this; } /// public virtual ITagDefinitionBuilder WithDescription(string? description) { - this.Tag.Description = description; + Tag.Description = description; return this; } @@ -53,16 +60,16 @@ public virtual ITagDefinitionBuilder WithDescription(string? description) public virtual ITagDefinitionBuilder WithExternalDocumentation(Uri uri, string? description = null) { ArgumentNullException.ThrowIfNull(uri); - this.Tag.ExternalDocs = new() { Url = uri, Description = description }; + Tag.ExternalDocs = new() { Url = uri, Description = description }; return this; } /// public virtual TagDefinition Build() { - var validationResults = this.Validators.Select(v => v.Validate(this.Tag)); + var validationResults = Validators.Select(v => v.Validate(Tag)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); - return this.Tag; + return Tag; } } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Usings.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Usings.cs index 850f2cf..99c2100 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Usings.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Usings.cs @@ -15,5 +15,7 @@ global using Json.Schema; global using Json.Schema.Generation; global using Microsoft.Extensions.DependencyInjection; +global using Neuroglia.AsyncApi.Bindings; global using Neuroglia.AsyncApi.v2; +global using Neuroglia.AsyncApi.v3; global using SemVersion; diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IAsyncApiDocumentBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2AsyncApiDocumentBuilder.cs similarity index 63% rename from src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IAsyncApiDocumentBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2AsyncApiDocumentBuilder.cs index a6b4819..a6fdd3f 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IAsyncApiDocumentBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2AsyncApiDocumentBuilder.cs @@ -11,57 +11,55 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.Bindings; - -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// /// Defines the fundamentals of a service used to build s /// -public interface IAsyncApiDocumentBuilder +public interface IV2AsyncApiDocumentBuilder { /// /// Configures the to use the specified Async Api Specification version /// /// The Async Api Specification version to use - /// The configured - IAsyncApiDocumentBuilder WithSpecVersion(string version); + /// The configured + IV2AsyncApiDocumentBuilder WithSpecVersion(string version); /// /// Configures the to use the specified id /// /// The id of the Async Api document to build - /// The configured - IAsyncApiDocumentBuilder WithId(string id); + /// The configured + IV2AsyncApiDocumentBuilder WithId(string id); /// /// Configures the to use the specified API title /// /// The title of the Async Api document to build - /// The configured - IAsyncApiDocumentBuilder WithTitle(string title); + /// The configured + IV2AsyncApiDocumentBuilder WithTitle(string title); /// /// Configures the to use the specified API version /// /// The version of the Async Api document to build - /// The configured - IAsyncApiDocumentBuilder WithVersion(string version); + /// The configured + IV2AsyncApiDocumentBuilder WithVersion(string version); /// /// Configures the to use the specified API description /// /// The description of the Async Api document to build - /// The configured - IAsyncApiDocumentBuilder WithDescription(string? description); + /// The configured + IV2AsyncApiDocumentBuilder WithDescription(string? description); /// /// Configures the to use the specified for the API's terms of service /// /// The of the API's terms of service - /// The configured - IAsyncApiDocumentBuilder WithTermsOfService(Uri uri); + /// The configured + IV2AsyncApiDocumentBuilder WithTermsOfService(Uri uri); /// /// Configures the to use the specified contact for the API @@ -69,182 +67,182 @@ public interface IAsyncApiDocumentBuilder /// The contact name /// The contact /// The contact email - /// The configured - IAsyncApiDocumentBuilder WithContact(string name, Uri? uri = null, string? email = null); + /// The configured + IV2AsyncApiDocumentBuilder WithContact(string name, Uri? uri = null, string? email = null); /// /// Configures the to use the specified license /// /// The name of the license to use /// The license's - /// The configured - IAsyncApiDocumentBuilder WithLicense(string name, Uri? uri = null); + /// The configured + IV2AsyncApiDocumentBuilder WithLicense(string name, Uri? uri = null); /// - /// Configures the to use the specified license + /// Configures the to use the specified default content type /// /// The content type to use by default - /// The configured - IAsyncApiDocumentBuilder WithDefaultContentType(string contentType); + /// The configured + IV2AsyncApiDocumentBuilder WithDefaultContentType(string contentType); /// /// Marks the to build with the specified tag /// /// An used to setup the tag to use - /// The configured - IAsyncApiDocumentBuilder WithTag(Action setup); + /// The configured + IV2AsyncApiDocumentBuilder WithTag(Action setup); /// /// Adds the specified external documentation to the to build /// /// The to the documentation to add /// The description of the documentation to add - /// The configured - IAsyncApiDocumentBuilder WithExternalDocumentation(Uri uri, string? description = null); + /// The configured + IV2AsyncApiDocumentBuilder WithExternalDocumentation(Uri uri, string? description = null); /// /// Adds the specified to the to build /// /// The name of the to add /// An used to setup the to add - /// The configured - IAsyncApiDocumentBuilder WithServer(string name, Action setup); + /// The configured + IV2AsyncApiDocumentBuilder WithServer(string name, Action setup); /// /// Adds the specified to the to build /// /// The name of the to add /// An used to setup the to add - /// The configured - IAsyncApiDocumentBuilder WithChannel(string name, Action setup); + /// The configured + IV2AsyncApiDocumentBuilder WithChannel(string name, Action setup); /// /// Adds the specified /// /// The name of the to add /// The to add - /// The configured - IAsyncApiDocumentBuilder WithSecurityScheme(string name, V2SecuritySchemeDefinition scheme); + /// The configured + IV2AsyncApiDocumentBuilder WithSecurityScheme(string name, V2SecuritySchemeDefinition scheme); /// /// Adds the specified /// /// The name of the to add /// An used to setup the to add - /// The configured - IAsyncApiDocumentBuilder WithSecurityScheme(string name, Action setup); + /// The configured + IV2AsyncApiDocumentBuilder WithSecurityScheme(string name, Action setup); /// /// Adds the specified /// /// The name of the to add /// The to add - /// The configured - IAsyncApiDocumentBuilder WithSchemaComponent(string name, JsonSchema schema); + /// The configured + IV2AsyncApiDocumentBuilder WithSchemaComponent(string name, JsonSchema schema); /// /// Adds the specified /// /// The name of the to add /// The to add - /// The configured - IAsyncApiDocumentBuilder WithMessageComponent(string name, V2MessageDefinition message); + /// The configured + IV2AsyncApiDocumentBuilder WithMessageComponent(string name, V2MessageDefinition message); /// /// Adds the specified /// /// The name of the to add /// An used to setup the to add - /// The configured - IAsyncApiDocumentBuilder WithMessageComponent(string name, Action setup); + /// The configured + IV2AsyncApiDocumentBuilder WithMessageComponent(string name, Action setup); /// /// Adds the specified /// /// The name of the to add /// The to add - /// The configured - IAsyncApiDocumentBuilder WithParameterComponent(string name, V2ParameterDefinition parameter); + /// The configured + IV2AsyncApiDocumentBuilder WithParameterComponent(string name, V2ParameterDefinition parameter); /// /// Adds the specified /// /// The name of the to add /// An used to setup the to add - /// The configured - IAsyncApiDocumentBuilder WithParameterComponent(string name, Action setup); + /// The configured + IV2AsyncApiDocumentBuilder WithParameterComponent(string name, Action setup); /// /// Adds the specified /// /// The name of the to add /// The to add - /// The configured - IAsyncApiDocumentBuilder WithCorrelationIdComponent(string name, CorrelationIdDefinition correlationId); + /// The configured + IV2AsyncApiDocumentBuilder WithCorrelationIdComponent(string name, CorrelationIdDefinition correlationId); /// /// Adds the specified /// /// The name of the to add /// The to add - /// The configured - IAsyncApiDocumentBuilder WithOperationTraitComponent(string name, V2OperationTraitDefinition trait); + /// The configured + IV2AsyncApiDocumentBuilder WithOperationTraitComponent(string name, V2OperationTraitDefinition trait); /// /// Adds the specified /// /// The name of the to add /// An used to setup the to add - /// The configured - IAsyncApiDocumentBuilder WithOperationTraitComponent(string name, Action setup); + /// The configured + IV2AsyncApiDocumentBuilder WithOperationTraitComponent(string name, Action setup); /// /// Adds the specified /// /// The name of the to add /// The to add - /// The configured - IAsyncApiDocumentBuilder WithMessageTraitComponent(string name, V2MessageTraitDefinition trait); + /// The configured + IV2AsyncApiDocumentBuilder WithMessageTraitComponent(string name, V2MessageTraitDefinition trait); /// /// Adds the specified /// /// The name of the to add /// An used to setup the to add - /// The configured - IAsyncApiDocumentBuilder WithMessageTraitComponent(string name, Action setup); + /// The configured + IV2AsyncApiDocumentBuilder WithMessageTraitComponent(string name, Action setup); /// /// Adds the specified /// /// The name of the to add /// The to add - /// The configured - IAsyncApiDocumentBuilder WithServerBindingComponent(string name, ServerBindingDefinitionCollection bindings); + /// The configured + IV2AsyncApiDocumentBuilder WithServerBindingComponent(string name, ServerBindingDefinitionCollection bindings); /// /// Adds the specified /// /// The name of the to add /// The to add - /// The configured - IAsyncApiDocumentBuilder WithChannelBindingComponent(string name, ChannelBindingDefinitionCollection bindings); + /// The configured + IV2AsyncApiDocumentBuilder WithChannelBindingComponent(string name, ChannelBindingDefinitionCollection bindings); /// /// Adds the specified /// /// The name of the to add /// The to add - /// The configured - IAsyncApiDocumentBuilder WithOperationBindingComponent(string name, OperationBindingDefinitionCollection bindings); + /// The configured + IV2AsyncApiDocumentBuilder WithOperationBindingComponent(string name, OperationBindingDefinitionCollection bindings); /// /// Adds the specified /// /// The name of the to add /// The to add - /// The configured - IAsyncApiDocumentBuilder WithMessageBindingComponent(string name, MessageBindingDefinitionCollection bindings); + /// The configured + IV2AsyncApiDocumentBuilder WithMessageBindingComponent(string name, MessageBindingDefinitionCollection bindings); /// /// Builds a new diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IChannelDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ChannelDefinitionBuilder.cs similarity index 68% rename from src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IChannelDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ChannelDefinitionBuilder.cs index 67240d0..9ae8ec1 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IChannelDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ChannelDefinitionBuilder.cs @@ -11,60 +11,57 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.Bindings; -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// /// Defines the fundamentals of a service used to build s /// -public interface IChannelDefinitionBuilder +public interface IV2ChannelDefinitionBuilder { /// /// Configures the to build to use the specified description /// /// The 's description - /// The configured - IChannelDefinitionBuilder WithDescription(string? description); + /// The configured + IV2ChannelDefinitionBuilder WithDescription(string? description); /// /// Adds a new to the to build /// /// The name of the to add /// An used to setup the to add - /// The configured - IChannelDefinitionBuilder WithParameter(string name, Action setup); + /// The configured + IV2ChannelDefinitionBuilder WithParameter(string name, Action setup); /// /// Adds the specified to the to build /// /// The to add - /// The configured - IChannelDefinitionBuilder WithBinding(IChannelBindingDefinition binding); + /// The configured + IV2ChannelDefinitionBuilder WithBinding(IChannelBindingDefinition binding); /// /// Defines and configures an operation of the to build /// /// The 's type /// An used to setup the Subscribe - /// The configured - IChannelDefinitionBuilder WithOperation(V2OperationType type, Action setup); + /// The configured + IV2ChannelDefinitionBuilder WithOperation(V2OperationType type, Action setup); /// /// Defines and configures the Subscribe operation of the to build /// /// An used to setup the Subscribe - /// The configured - IChannelDefinitionBuilder WithSubscribeOperation(Action setup); + /// The configured + IV2ChannelDefinitionBuilder WithSubscribeOperation(Action setup); /// /// Defines and configures the Publish operation of the to build /// /// An used to setup the Publish - /// The configured - IChannelDefinitionBuilder WithPublishOperation(Action setup); + /// The configured + IV2ChannelDefinitionBuilder WithPublishOperation(Action setup); /// /// Builds a new diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2MessageDefinitionBuilder.cs similarity index 67% rename from src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2MessageDefinitionBuilder.cs index 394c55c..f1165bd 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2MessageDefinitionBuilder.cs @@ -11,55 +11,55 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// /// Defines the fundamentals of a service used to build s /// -public interface IMessageDefinitionBuilder - : IMessageTraitDefinitionBuilder +public interface IV2MessageDefinitionBuilder + : IV2MessageTraitDefinitionBuilder { /// /// Configures the to build to use the specified payload /// /// The used to define the 's payload - /// The configured - IMessageDefinitionBuilder WithPayloadSchema(JsonSchema payloadSchema); + /// The configured + IV2MessageDefinitionBuilder WithPayloadSchema(JsonSchema payloadSchema); /// /// Configures the to build to use the specified payload /// /// The type used to define the 's payload - /// The configured - IMessageDefinitionBuilder WithPayloadOfType(); + /// The configured + IV2MessageDefinitionBuilder WithPayloadOfType(); /// /// Configures the to build to use the specified payload /// /// The type used to define the 's payload - /// The configured - IMessageDefinitionBuilder WithPayloadOfType(Type payloadType); + /// The configured + IV2MessageDefinitionBuilder WithPayloadOfType(Type payloadType); /// /// Configures the to build to use the specified /// /// An used to setup the to use - /// The configured - IMessageDefinitionBuilder WithTrait(Action setup); + /// The configured + IV2MessageDefinitionBuilder WithTrait(Action setup); /// /// Configures the to build to use the specified /// /// An used to setup the to use - /// The configured - IMessageDefinitionBuilder WithTrait(V2MessageTraitDefinition trait); + /// The configured + IV2MessageDefinitionBuilder WithTrait(V2MessageTraitDefinition trait); /// /// Configures the to build to use the specified /// /// The reference to the to use - /// The configured - IMessageDefinitionBuilder WithTraitReference(string reference); + /// The configured + IV2MessageDefinitionBuilder WithTraitReference(string reference); } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2MessageTraitDefinitionBuilder.cs similarity index 73% rename from src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageTraitDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2MessageTraitDefinitionBuilder.cs index 244cd04..561cc45 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2MessageTraitDefinitionBuilder.cs @@ -11,17 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.Bindings; - -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// /// Defines the fundamentals of a service used to build s /// -/// The type of to return for chaining purposes +/// The type of to return for chaining purposes /// The type of to build -public interface IMessageTraitDefinitionBuilder - where TBuilder : IMessageTraitDefinitionBuilder +public interface IV2MessageTraitDefinitionBuilder + where TBuilder : IV2MessageTraitDefinitionBuilder where TTrait : V2MessageTraitDefinition { @@ -29,7 +27,7 @@ public interface IMessageTraitDefinitionBuilder /// Configures the to build to use the specified headers /// /// The type used to define the 's headers - /// The configured + /// The configured TBuilder WithHeaders() where THeaders : class; @@ -37,14 +35,14 @@ TBuilder WithHeaders() /// Configures the to build to use the specified headers /// /// The type used to define the 's headers - /// The configured + /// The configured TBuilder WithHeaders(Type headersType); /// /// Configures the to build to use the specified headers /// /// The used to define the 's headers - /// The configured + /// The configured TBuilder WithHeaders(JsonSchema headersSchema); /// @@ -52,7 +50,7 @@ TBuilder WithHeaders() /// /// The location of the correlation id to use /// The description of the correlation id to use - /// The configured + /// The configured TBuilder WithCorrelationId(string location, string? description = null); /// @@ -60,62 +58,63 @@ TBuilder WithHeaders() /// /// An used to build the runtime expression referencing the location of the correlation id to use /// The description of the correlation id to use - /// The configured + /// The configured TBuilder WithCorrelationId(Action locationSetup, string? description = null); /// /// Configures the to build to use the specified schema format /// /// The schema format to use - /// The configured + /// The configured TBuilder WithSchemaFormat(string schemaFormat); /// /// Configures the to build to use the specified content type /// /// The content type to use - /// The configured + /// The configured TBuilder WithContentType(string contentType); /// /// Configures the to build to use the specified content type /// /// The name to use - /// The configured + /// The configured TBuilder WithName(string name); /// /// Configures the to build to use the specified title /// /// The title to use - /// The configured + /// The configured TBuilder WithTitle(string title); /// /// Configures the to build to use the specified summary /// /// The summary to use - /// The configured + /// The configured TBuilder WithSummary(string summary); /// /// Configures the to build to use the specified description /// /// The description to use - /// The configured + /// The configured TBuilder WithDescription(string? description); + /// /// Adds the specified to the to build /// /// The to add - /// The configured + /// The configured TBuilder WithBinding(IMessageBindingDefinition binding); /// /// Marks the to build with the specified tag /// /// An used to setup the tag to use - /// The configured + /// The configured TBuilder WithTag(Action setup); /// @@ -123,7 +122,7 @@ TBuilder WithHeaders() /// /// The name of the example to add /// The example to use - /// The configured + /// The configured TBuilder WithExample(string name, object example); /// @@ -131,7 +130,7 @@ TBuilder WithHeaders() /// /// The to the documentation to add /// The description of the documentation to add - /// The configured + /// The configured TBuilder WithExternalDocumentation(Uri uri, string? description = null); /// @@ -145,8 +144,8 @@ TBuilder WithHeaders() /// /// Defines the fundamentals of a service used to build s /// -public interface IMessageTraitBuilder - : IMessageTraitDefinitionBuilder +public interface IV2MessageTraitDefinitionBuilder + : IV2MessageTraitDefinitionBuilder { diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2OperationDefinitionBuilder.cs similarity index 69% rename from src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2OperationDefinitionBuilder.cs index 094f461..9f68e2c 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2OperationDefinitionBuilder.cs @@ -11,36 +11,34 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// /// Defines the fundamentals of a service used to build s /// -public interface IOperationDefinitionBuilder - : IOperationTraitDefinitionBuilder +public interface IV2OperationDefinitionBuilder + : IV2OperationTraitDefinitionBuilder { /// /// Configures the to build to use the specified /// /// An used to setup the to use - /// The configured - IOperationDefinitionBuilder WithTrait(Action setup); + /// The configured + IV2OperationDefinitionBuilder WithTrait(Action setup); /// /// Configures the to build to use the specified /// /// An used to setup the to use - /// The configured - IOperationDefinitionBuilder WithMessage(Action setup); + /// The configured + IV2OperationDefinitionBuilder WithMessage(Action setup); /// /// Configures the to build to use the specified s /// /// An array containing the used to setup the s to use - /// The configured - IOperationDefinitionBuilder WithMessages(params Action[] setups); + /// The configured + IV2OperationDefinitionBuilder WithMessages(params Action[] setups); } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2OperationTraitDefinitionBuilder.cs similarity index 72% rename from src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationTraitDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2OperationTraitDefinitionBuilder.cs index 58f907e..39906bc 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2OperationTraitDefinitionBuilder.cs @@ -11,18 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.Bindings; -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// /// Defines the fundamentals of a service used to build s /// -/// The type of to return for chaining purposes +/// The type of to return for chaining purposes /// The type of to build -public interface IOperationTraitDefinitionBuilder - where TBuilder : IOperationTraitDefinitionBuilder +public interface IV2OperationTraitDefinitionBuilder + where TBuilder : IV2OperationTraitDefinitionBuilder where TTrait : V2OperationTraitDefinition { @@ -30,28 +27,28 @@ public interface IOperationTraitDefinitionBuilder /// Configures the to use the specified id /// /// The id of the Async Api document to build - /// The configured + /// The configured TBuilder WithOperationId(string operationId); /// /// Configures the to use the specified API description /// /// The summary of the Async Api document to build - /// The configured + /// The configured TBuilder WithSummary(string summary); /// /// Configures the to use the specified API description /// /// The description of the Async Api document to build - /// The configured + /// The configured TBuilder WithDescription(string? description); /// /// Marks the to build with the specified tag /// /// An used to setup the tag to use - /// The configured + /// The configured TBuilder WithTag(Action setup); /// @@ -59,14 +56,14 @@ public interface IOperationTraitDefinitionBuilder /// /// The to the documentation to add /// The description of the documentation to add - /// The configured + /// The configured TBuilder WithExternalDocumentation(Uri uri, string? description = null); /// /// Adds the specified to the to build /// /// The to add - /// The configured + /// The configured TBuilder WithBinding(IOperationBindingDefinition binding); /// @@ -80,8 +77,8 @@ public interface IOperationTraitDefinitionBuilder /// /// Defines the fundamentals of a service used to build s /// -public interface IOperationTraitBuilder - : IOperationTraitDefinitionBuilder +public interface IV2OperationTraitDefinitionBuilder + : IV2OperationTraitDefinitionBuilder { diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IParameterDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ParameterDefinitionBuilder.cs similarity index 71% rename from src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IParameterDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ParameterDefinitionBuilder.cs index f434021..99e3f82 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IParameterDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ParameterDefinitionBuilder.cs @@ -11,50 +11,48 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// /// Defines the fundamentals of the service used to build s /// -public interface IParameterDefinitionBuilder +public interface IV2ParameterDefinitionBuilder { /// /// Configures the type of the to build /// /// The type of the to build - /// The configured - IParameterDefinitionBuilder OfType(); + /// The configured + IV2ParameterDefinitionBuilder OfType(); /// /// Configures the type of the to build /// /// The type of the to build - /// The configured - IParameterDefinitionBuilder OfType(Type parameterType); + /// The configured + IV2ParameterDefinitionBuilder OfType(Type parameterType); /// /// Configures the of the to build /// /// The of the to build - /// The configured - IParameterDefinitionBuilder WithSchema(JsonSchema schema); + /// The configured + IV2ParameterDefinitionBuilder WithSchema(JsonSchema schema); /// /// Configures the to build to use the specified description /// /// The description to use - /// The configured - IParameterDefinitionBuilder WithDescription(string? description); + /// The configured + IV2ParameterDefinitionBuilder WithDescription(string? description); /// /// Sets the location of the to build /// /// A runtime expression that specifies the location of the parameter value - /// The configured - IParameterDefinitionBuilder WithLocation(string location); + /// The configured + IV2ParameterDefinitionBuilder WithLocation(string location); /// /// Builds a new diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ISecuritySchemeDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2SecuritySchemeDefinitionBuilder.cs similarity index 67% rename from src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ISecuritySchemeDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2SecuritySchemeDefinitionBuilder.cs index 604d401..8863d24 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ISecuritySchemeDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2SecuritySchemeDefinitionBuilder.cs @@ -11,69 +11,69 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// /// Defines the fundamentals of a service used to build s /// -public interface ISecuritySchemeDefinitionBuilder +public interface IV2SecuritySchemeDefinitionBuilder { /// /// Configures the to build to be of the specified /// /// The of the to build - /// The configured - ISecuritySchemeDefinitionBuilder WithType(SecuritySchemeType type); + /// The configured + IV2SecuritySchemeDefinitionBuilder WithType(SecuritySchemeType type); /// /// Configures the to build to use the specified name /// /// The 's name - /// The configured - ISecuritySchemeDefinitionBuilder WithParameterName(string? name); + /// The configured + IV2SecuritySchemeDefinitionBuilder WithParameterName(string? name); /// /// Configures the to build to use the specified description /// /// The 's description - /// The configured - ISecuritySchemeDefinitionBuilder WithDescription(string? location); + /// The configured + IV2SecuritySchemeDefinitionBuilder WithDescription(string? location); /// /// Configures the to build to store API keys at the specified location /// /// The location to store the API key at - /// The configured - ISecuritySchemeDefinitionBuilder WithApiKeyLocation(string? location); + /// The configured + IV2SecuritySchemeDefinitionBuilder WithApiKeyLocation(string? location); /// /// Configures the to build to use the specified scheme name in the Authorization header, as defined in RFC7235. /// /// The name of the authorization scheme to use - /// The configured - ISecuritySchemeDefinitionBuilder WithAuthorizationScheme(string? scheme); + /// The configured + IV2SecuritySchemeDefinitionBuilder WithAuthorizationScheme(string? scheme); /// /// Configures the to build to use the specified object hint for the client to identify how the bearer token is formatted /// /// The bearer format to use - /// The configured - ISecuritySchemeDefinitionBuilder WithBearerFormat(string? format); + /// The configured + IV2SecuritySchemeDefinitionBuilder WithBearerFormat(string? format); /// /// Configures the to build to use the specified OpenId Connect to discover OAuth2 configuration values /// /// The OpenId Connect at which to discover OAuth2 configuration values - /// The configured - ISecuritySchemeDefinitionBuilder WithOpenIdConnectUrl(Uri? uri); + /// The configured + IV2SecuritySchemeDefinitionBuilder WithOpenIdConnectUrl(Uri? uri); /// /// Configures the to build to use the specified OAUTH flows /// /// An used to build the s to use - /// The configured - ISecuritySchemeDefinitionBuilder WithOAuthFlows(Action setup); + /// The configured + IV2SecuritySchemeDefinitionBuilder WithOAuthFlows(Action setup); /// /// Builds a new diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ServerDefinitionBuilder.cs similarity index 70% rename from src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ServerDefinitionBuilder.cs index 33f3aa0..eb6df73 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ServerDefinitionBuilder.cs @@ -11,60 +11,58 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.Bindings; - -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// /// Defines the fundamentals of a service used to build s /// -public interface IServerDefinitionBuilder +public interface IV2ServerDefinitionBuilder { /// /// Configures the to use the specified url /// /// The of the to build - /// The configured - IServerDefinitionBuilder WithUrl(Uri uri); + /// The configured + IV2ServerDefinitionBuilder WithUrl(Uri uri); /// /// Configures the to use the specified protocol /// /// The protocol to use /// The protocol version to use - /// The configured - IServerDefinitionBuilder WithProtocol(string protocol, string? version = null); + /// The configured + IV2ServerDefinitionBuilder WithProtocol(string protocol, string? version = null); /// /// Configures the to use the specified description /// /// The description to use - /// The configured - IServerDefinitionBuilder WithDescription(string? description); + /// The configured + IV2ServerDefinitionBuilder WithDescription(string? description); /// /// Adds the specified to the to build /// /// The name of the to add /// An used to setup the to add - /// The configured - IServerDefinitionBuilder WithVariable(string name, Action setup); + /// The configured + IV2ServerDefinitionBuilder WithVariable(string name, Action setup); /// /// Configures the to build to use the specified /// /// The name of the to add /// The security requirement object, if any - /// The configured - IServerDefinitionBuilder WithSecurityRequirement(string name, object? requirement = null); + /// The configured + IV2ServerDefinitionBuilder WithSecurityRequirement(string name, object? requirement = null); /// /// Adds the specified to the to build /// /// The to add - /// The configured - IServerDefinitionBuilder WithBinding(IServerBindingDefinition binding); + /// The configured + IV2ServerDefinitionBuilder WithBinding(IServerBindingDefinition binding); /// /// Builds a new diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2AsyncApiDocumentBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2AsyncApiDocumentBuilder.cs new file mode 100644 index 0000000..b36e68a --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2AsyncApiDocumentBuilder.cs @@ -0,0 +1,343 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v2; + +/// +/// Represents the default implementation of the +/// +/// +/// Initializes a new +/// +/// The current +/// The services used to validate s +public class V2AsyncApiDocumentBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV2AsyncApiDocumentBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected virtual V2AsyncApiDocument Document { get; } = new(); + + /// + public virtual IV2AsyncApiDocumentBuilder WithSpecVersion(string version) + { + if (string.IsNullOrWhiteSpace(version)) throw new ArgumentNullException(nameof(version)); + if (!SemanticVersion.TryParse(version, out _)) throw new ArgumentException($"The specified value '{version}' is not a valid semantic version", nameof(version)); + Document.AsyncApi = version; + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithId(string id) + { + Document.Id = id; + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithTitle(string title) + { + if (string.IsNullOrWhiteSpace(title)) throw new ArgumentNullException(nameof(title)); + Document.Info ??= new(); + Document.Info.Title = title; + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithVersion(string version) + { + if (string.IsNullOrWhiteSpace(version)) throw new ArgumentNullException(nameof(version)); + if (!SemanticVersion.TryParse(version, out _)) throw new ArgumentException($"The specified value '{version}' is not a valid semantic version", nameof(version)); + if (Document.Info == null) Document.Info = new(); + Document.Info.Version = version; + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithDescription(string? description) + { + if (Document.Info == null) Document.Info = new(); + Document.Info.Description = description; + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithTermsOfService(Uri uri) + { + if (Document.Info == null) Document.Info = new(); + Document.Info.TermsOfService = uri; + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithContact(string name, Uri? uri = null, string? email = null) + { + if (Document.Info == null) Document.Info = new(); + Document.Info.Contact = new() { Name = name, Url = uri, Email = email }; + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithLicense(string name, Uri? uri = null) + { + if (Document.Info == null) Document.Info = new(); + Document.Info.License = new() { Name = name, Url = uri }; + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithDefaultContentType(string contentType) + { + Document.DefaultContentType = contentType; + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithTag(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + Document.Tags ??= []; + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + setup(builder); + Document.Tags.Add(builder.Build()); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithExternalDocumentation(Uri uri, string? description = null) + { + ArgumentNullException.ThrowIfNull(uri); + Document.ExternalDocs = new() { Url = uri, Description = description }; + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithServer(string name, Action setup) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(setup); + if (Document.Servers == null) Document.Servers = []; + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + setup(builder); + Document.Servers.Add(name, builder.Build()); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithChannel(string name, Action setup) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(setup); + Document.Channels ??= []; + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + setup(builder); + Document.Channels.Add(name, builder.Build()); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithSecurityScheme(string name, V2SecuritySchemeDefinition scheme) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(scheme); + if (Document.Components == null) Document.Components = new(); + if (Document.Components.SecuritySchemes == null) Document.Components.SecuritySchemes = []; + Document.Components.SecuritySchemes.Add(name, scheme); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithSecurityScheme(string name, Action setup) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(setup); + Document.Components ??= new(); + Document.Components.SecuritySchemes ??= []; + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + setup(builder); + Document.Components.SecuritySchemes.Add(name, builder.Build()); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithSchemaComponent(string name, JsonSchema schema) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(schema); + if (Document.Components == null) Document.Components = new(); + if (Document.Components.Schemas == null) Document.Components.Schemas = []; + Document.Components.Schemas.Add(name, schema); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithMessageComponent(string name, V2MessageDefinition message) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(message); + if (Document.Components == null) Document.Components = new(); + if (Document.Components.Messages == null) Document.Components.Messages = []; + Document.Components.Messages.Add(name, message); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithMessageComponent(string name, Action setup) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + setup(builder); + return WithMessageComponent(name, builder.Build()); + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithParameterComponent(string name, V2ParameterDefinition parameter) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(parameter); + if (Document.Components == null) Document.Components = new(); + if (Document.Components.Parameters == null) Document.Components.Parameters = []; + Document.Components.Parameters.Add(name, parameter); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithParameterComponent(string name, Action setup) + { + if (string.IsNullOrWhiteSpace(name)) + throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + setup(builder); + return WithParameterComponent(name, builder.Build()); + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithCorrelationIdComponent(string name, CorrelationIdDefinition correlationId) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(correlationId); + if (Document.Components == null) Document.Components = new(); + if (Document.Components.CorrelationIds == null) Document.Components.CorrelationIds = []; + Document.Components.CorrelationIds.Add(name, correlationId); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithOperationTraitComponent(string name, V2OperationTraitDefinition trait) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(trait); + if (Document.Components == null) Document.Components = new(); + if (Document.Components.OperationTraits == null) Document.Components.OperationTraits = []; + Document.Components.OperationTraits.Add(name, trait); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithOperationTraitComponent(string name, Action setup) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + setup(builder); + return WithOperationTraitComponent(name, builder.Build()); + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithMessageTraitComponent(string name, V2MessageTraitDefinition trait) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(trait); + if (Document.Components == null) Document.Components = new(); + if (Document.Components.MessageTraits == null) Document.Components.MessageTraits = []; + Document.Components.MessageTraits.Add(name, trait); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithMessageTraitComponent(string name, Action setup) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + setup(builder); + return WithMessageTraitComponent(name, builder.Build()); + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithServerBindingComponent(string name, ServerBindingDefinitionCollection bindings) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(bindings); + if (Document.Components == null) Document.Components = new(); + if (Document.Components.ServerBindings == null) Document.Components.ServerBindings = []; + Document.Components.ServerBindings.Add(name, bindings); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithChannelBindingComponent(string name, ChannelBindingDefinitionCollection bindings) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(bindings); + if (Document.Components == null) Document.Components = new(); + if (Document.Components.ChannelBindings == null) Document.Components.ChannelBindings = []; + Document.Components.ChannelBindings.Add(name, bindings); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithOperationBindingComponent(string name, OperationBindingDefinitionCollection bindings) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(bindings); + if (Document.Components == null) Document.Components = new(); + if (Document.Components.OperationBindings == null) Document.Components.OperationBindings = []; + Document.Components.OperationBindings.Add(name, bindings); + return this; + } + + /// + public virtual IV2AsyncApiDocumentBuilder WithMessageBindingComponent(string name, MessageBindingDefinitionCollection bindings) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + ArgumentNullException.ThrowIfNull(bindings); + if (Document.Components == null) Document.Components = new(); + if (Document.Components.MessageBindings == null) Document.Components.MessageBindings = []; + Document.Components.MessageBindings.Add(name, bindings); + return this; + } + + /// + public virtual V2AsyncApiDocument Build() + { + var validationResults = Validators.Select(v => v.Validate(Document)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); + return Document; + } + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/ChannelDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ChannelDefinitionBuilder.cs similarity index 59% rename from src/Neuroglia.AsyncApi.FluentBuilders/ChannelDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ChannelDefinitionBuilder.cs index 1791174..ccc249b 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/ChannelDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ChannelDefinitionBuilder.cs @@ -11,21 +11,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.Bindings; -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// -/// Represents the default implementation of the +/// Represents the default implementation of the /// /// -/// Initializes a new +/// Initializes a new /// /// The current /// The services used to validate s -public class ChannelDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : IChannelDefinitionBuilder +public class V2ChannelDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV2ChannelDefinitionBuilder { /// @@ -44,46 +41,46 @@ public class ChannelDefinitionBuilder(IServiceProvider serviceProvider, IEnumera protected virtual V2ChannelDefinition Channel { get; } = new(); /// - public virtual IChannelDefinitionBuilder WithDescription(string? description) + public virtual IV2ChannelDefinitionBuilder WithDescription(string? description) { - this.Channel.Description = description; + Channel.Description = description; return this; } /// - public virtual IChannelDefinitionBuilder WithParameter(string name, Action setup) + public virtual IV2ChannelDefinitionBuilder WithParameter(string name, Action setup) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); ArgumentNullException.ThrowIfNull(setup); - this.Channel.Parameters ??= []; - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + Channel.Parameters ??= []; + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); - this.Channel.Parameters.Add(name, builder.Build()); + Channel.Parameters.Add(name, builder.Build()); return this; } /// - public virtual IChannelDefinitionBuilder WithBinding(IChannelBindingDefinition binding) + public virtual IV2ChannelDefinitionBuilder WithBinding(IChannelBindingDefinition binding) { ArgumentNullException.ThrowIfNull(binding); - this.Channel.Bindings ??= new(); - this.Channel.Bindings.Add(binding); + Channel.Bindings ??= new(); + Channel.Bindings.Add(binding); return this; } /// - public virtual IChannelDefinitionBuilder WithOperation(V2OperationType type, Action setup) + public virtual IV2ChannelDefinitionBuilder WithOperation(V2OperationType type, Action setup) { ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); switch (type) { case V2OperationType.Publish: - this.Channel.Publish = builder.Build(); + Channel.Publish = builder.Build(); break; case V2OperationType.Subscribe: - this.Channel.Subscribe = builder.Build(); + Channel.Subscribe = builder.Build(); break; default: throw new NotSupportedException($"The specified operation type '{type}' is not supported"); @@ -92,17 +89,17 @@ public virtual IChannelDefinitionBuilder WithOperation(V2OperationType type, Act } /// - public virtual IChannelDefinitionBuilder WithSubscribeOperation(Action setup) => this.WithOperation(V2OperationType.Subscribe, setup); + public virtual IV2ChannelDefinitionBuilder WithSubscribeOperation(Action setup) => WithOperation(V2OperationType.Subscribe, setup); /// - public virtual IChannelDefinitionBuilder WithPublishOperation(Action setup) => this.WithOperation(V2OperationType.Publish, setup); + public virtual IV2ChannelDefinitionBuilder WithPublishOperation(Action setup) => WithOperation(V2OperationType.Publish, setup); /// public virtual V2ChannelDefinition Build() { - var validationResults = this.Validators.Select(v => v.Validate(this.Channel)); + var validationResults = Validators.Select(v => v.Validate(Channel)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); - return this.Channel; + return Channel; } } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/MessageDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2MessageDefinitionBuilder.cs similarity index 50% rename from src/Neuroglia.AsyncApi.FluentBuilders/MessageDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/V2MessageDefinitionBuilder.cs index f49f099..a9c7b18 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/MessageDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2MessageDefinitionBuilder.cs @@ -13,67 +13,67 @@ using Neuroglia.Data.Schemas.Json; -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// -/// Represents the default implementation of the interface +/// Represents the default implementation of the interface /// /// -/// Initializes a new +/// Initializes a new /// /// The current /// An containing the services used to validate s -public class MessageDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : MessageTraitDefinitionBuilder(serviceProvider, validators), IMessageDefinitionBuilder +public class V2MessageDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : V2MessageTraitDefinitionBuilder(serviceProvider, validators), IV2MessageDefinitionBuilder { /// - public virtual IMessageDefinitionBuilder WithPayloadOfType() => this.WithPayloadOfType(typeof(TPayload)); + public virtual IV2MessageDefinitionBuilder WithPayloadOfType() => WithPayloadOfType(typeof(TPayload)); /// - public virtual IMessageDefinitionBuilder WithPayloadOfType(Type payloadType) + public virtual IV2MessageDefinitionBuilder WithPayloadOfType(Type payloadType) { ArgumentNullException.ThrowIfNull(payloadType); - return this.WithPayloadSchema(new JsonSchemaBuilder().FromType(payloadType, JsonSchemaGeneratorConfiguration.Default)); + return WithPayloadSchema(new JsonSchemaBuilder().FromType(payloadType, JsonSchemaGeneratorConfiguration.Default)); } /// - public virtual IMessageDefinitionBuilder WithPayloadSchema(JsonSchema payloadSchema) + public virtual IV2MessageDefinitionBuilder WithPayloadSchema(JsonSchema payloadSchema) { ArgumentNullException.ThrowIfNull(payloadSchema); - this.Trait.Payload = payloadSchema; + Trait.Payload = payloadSchema; return this; } /// - public virtual IMessageDefinitionBuilder WithTrait(Action setup) + public virtual IV2MessageDefinitionBuilder WithTrait(Action setup) { ArgumentNullException.ThrowIfNull(setup); - this.Trait.Traits ??= []; - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + Trait.Traits ??= []; + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); - this.Trait.Traits.Add(builder.Build()); + Trait.Traits.Add(builder.Build()); return this; } /// - public virtual IMessageDefinitionBuilder WithTrait(V2MessageTraitDefinition trait) + public virtual IV2MessageDefinitionBuilder WithTrait(V2MessageTraitDefinition trait) { ArgumentNullException.ThrowIfNull(trait); - this.Trait.Traits ??= []; - this.Trait.Traits.Add(trait); + Trait.Traits ??= []; + Trait.Traits.Add(trait); return this; } /// - public virtual IMessageDefinitionBuilder WithTraitReference(string reference) + public virtual IV2MessageDefinitionBuilder WithTraitReference(string reference) { if (string.IsNullOrWhiteSpace(reference)) throw new ArgumentNullException(nameof(reference)); - return this.WithTrait(new V2MessageTraitDefinition() { Reference = reference }); + return WithTrait(new V2MessageTraitDefinition() { Reference = reference }); } } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2MessageTraitDefinitionBuilder.cs similarity index 63% rename from src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/V2MessageTraitDefinitionBuilder.cs index a745f6a..78a99c4 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/MessageTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2MessageTraitDefinitionBuilder.cs @@ -11,31 +11,30 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.Bindings; using Neuroglia.Data.Schemas.Json; -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// -/// Represents the base class for all implementations +/// Represents the base class for all implementations /// -/// The type of to return for chaining purposes +/// The type of to return for chaining purposes /// The type of to build -public abstract class MessageTraitDefinitionBuilder - : IMessageTraitDefinitionBuilder - where TBuilder : IMessageTraitDefinitionBuilder +public abstract class V2MessageTraitDefinitionBuilder + : IV2MessageTraitDefinitionBuilder + where TBuilder : IV2MessageTraitDefinitionBuilder where TTrait : V2MessageTraitDefinition, new() { /// - /// Initializes a new + /// Initializes a new /// /// The current /// An containing the services used to validate s - protected MessageTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + protected V2MessageTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) { - this.ServiceProvider = serviceProvider; - this.Validators = validators; + ServiceProvider = serviceProvider; + Validators = validators; } /// @@ -58,8 +57,8 @@ public virtual TBuilder WithExample(string name, object example) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); ArgumentNullException.ThrowIfNull(example); - this.Trait.Examples ??= []; - this.Trait.Examples.Add(name, example); + Trait.Examples ??= []; + Trait.Examples.Add(name, example); return (TBuilder)(object)this; } @@ -67,7 +66,7 @@ public virtual TBuilder WithExample(string name, object example) public virtual TBuilder WithExternalDocumentation(Uri uri, string? description = null) { ArgumentNullException.ThrowIfNull(uri); - this.Trait.ExternalDocs = new ExternalDocumentationDefinition() { Url = uri, Description = description }; + Trait.ExternalDocs = new ExternalDocumentationDefinition() { Url = uri, Description = description }; return (TBuilder)(object)this; } @@ -75,10 +74,10 @@ public virtual TBuilder WithExternalDocumentation(Uri uri, string? description = public virtual TBuilder WithTag(Action setup) { ArgumentNullException.ThrowIfNull(setup); - this.Trait.Tags ??= []; - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + Trait.Tags ??= []; + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); - this.Trait.Tags.Add(builder.Build()); + Trait.Tags.Add(builder.Build()); return (TBuilder)(object)this; } @@ -86,15 +85,15 @@ public virtual TBuilder WithTag(Action setup) public virtual TBuilder WithBinding(IMessageBindingDefinition binding) { ArgumentNullException.ThrowIfNull(binding); - this.Trait.Bindings ??= new(); - this.Trait.Bindings.Add(binding); + Trait.Bindings ??= new(); + Trait.Bindings.Add(binding); return (TBuilder)(object)this; } /// public virtual TBuilder WithContentType(string contentType) { - this.Trait.ContentType = contentType; + Trait.ContentType = contentType; return (TBuilder)(object)this; } @@ -102,7 +101,7 @@ public virtual TBuilder WithContentType(string contentType) public virtual TBuilder WithCorrelationId(string location, string? description = null) { if (string.IsNullOrWhiteSpace(location)) throw new ArgumentNullException(nameof(location)); - this.Trait.CorrelationId = new() { Location = location, Description = description }; + Trait.CorrelationId = new() { Location = location, Description = description }; return (TBuilder)(object)this; } @@ -111,67 +110,78 @@ public virtual TBuilder WithCorrelationId(Action loca { var expressionBuilder = new RuntimeExpressionBuilder(); locationSetup(expressionBuilder); - return this.WithCorrelationId(expressionBuilder.Build().ToString(), description); + return WithCorrelationId(expressionBuilder.Build().ToString(), description); } /// public virtual TBuilder WithDescription(string? description) { - this.Trait.Description = description; + Trait.Description = description; return (TBuilder)(object)this; } /// - public virtual TBuilder WithHeaders() where THeaders : class => this.WithHeaders(typeof(THeaders)); + public virtual TBuilder WithHeaders() where THeaders : class => WithHeaders(typeof(THeaders)); /// public virtual TBuilder WithHeaders(Type headersType) { ArgumentNullException.ThrowIfNull(headersType); - return this.WithHeaders(new JsonSchemaBuilder().FromType(headersType, JsonSchemaGeneratorConfiguration.Default)); + return WithHeaders(new JsonSchemaBuilder().FromType(headersType, JsonSchemaGeneratorConfiguration.Default)); } /// public virtual TBuilder WithHeaders(JsonSchema headersSchema) { - this.Trait.Headers = headersSchema ?? throw new ArgumentNullException(nameof(headersSchema)); + Trait.Headers = headersSchema ?? throw new ArgumentNullException(nameof(headersSchema)); return (TBuilder)(object)this; } /// public virtual TBuilder WithName(string name) { - this.Trait.Name = name; + Trait.Name = name; return (TBuilder)(object)this; } /// public virtual TBuilder WithSchemaFormat(string schemaFormat) { - this.Trait.SchemaFormat = schemaFormat; + Trait.SchemaFormat = schemaFormat; return (TBuilder)(object)this; } /// public virtual TBuilder WithSummary(string summary) { - this.Trait.Summary = summary; + Trait.Summary = summary; return (TBuilder)(object)this; } /// public virtual TBuilder WithTitle(string title) { - this.Trait.Title = title; + Trait.Title = title; return (TBuilder)(object)this; } /// public virtual TTrait Build() { - var validationResults = this.Validators.Select(v => v.Validate(this.Trait)); + var validationResults = Validators.Select(v => v.Validate(Trait)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); - return this.Trait; + return Trait; } } + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// An containing the services used to validate s +public class V2MessageTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : V2MessageTraitDefinitionBuilder(serviceProvider, validators), IV2MessageTraitDefinitionBuilder +{ + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/OperationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2OperationDefinitionBuilder.cs similarity index 55% rename from src/Neuroglia.AsyncApi.FluentBuilders/OperationDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/V2OperationDefinitionBuilder.cs index c83a8d0..03afe4d 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/OperationDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2OperationDefinitionBuilder.cs @@ -11,42 +11,42 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// -/// Represents the base class for all implementations +/// Represents the base class for all implementations /// /// -/// Initializes a new +/// Initializes a new /// /// The current /// An containing the services used to validate s -public class OperationDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : OperationTraitDefinitionBuilder(serviceProvider, validators), IOperationDefinitionBuilder +public class V2OperationDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : V2OperationTraitDefinitionBuilder(serviceProvider, validators), IV2OperationDefinitionBuilder { /// - public virtual IOperationDefinitionBuilder WithMessage(Action setup) + public virtual IV2OperationDefinitionBuilder WithMessage(Action setup) { ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); - this.Trait.Message = V2OperationMessageDefinition.From(builder.Build()); + Trait.Message = V2OperationMessageDefinition.From(builder.Build()); return this; } /// - public virtual IOperationDefinitionBuilder WithMessages(params Action[] setups) + public virtual IV2OperationDefinitionBuilder WithMessages(params Action[] setups) { if (setups == null || setups.Length == 0) return this; - this.Trait.Message = new() + Trait.Message = new() { OneOf = new(setups.Select(setup => { - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); return V2OperationMessageDefinition.From(builder.Build()); })) @@ -56,14 +56,14 @@ public virtual IOperationDefinitionBuilder WithMessages(params Action - public virtual IOperationDefinitionBuilder WithTrait(Action setup) + public virtual IV2OperationDefinitionBuilder WithTrait(Action setup) { ArgumentNullException.ThrowIfNull(setup); - this.Trait.Traits ??= []; - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + Trait.Traits ??= []; + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); - this.Trait.Traits.Add(builder.Build()); + Trait.Traits.Add(builder.Build()); return this; } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2OperationTraitDefinitionBuilder.cs similarity index 58% rename from src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/V2OperationTraitDefinitionBuilder.cs index cfd875e..fbeab33 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/OperationTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2OperationTraitDefinitionBuilder.cs @@ -11,31 +11,28 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.Bindings; -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// -/// Represents the base class for all implementations +/// Represents the base class for all implementations /// -/// The type of to return for chaining purposes +/// The type of to return for chaining purposes /// The type of to build -public abstract class OperationTraitDefinitionBuilder - : IOperationTraitDefinitionBuilder - where TBuilder : IOperationTraitDefinitionBuilder +public abstract class V2OperationTraitDefinitionBuilder + : IV2OperationTraitDefinitionBuilder + where TBuilder : IV2OperationTraitDefinitionBuilder where TTrait : V2OperationTraitDefinition, new() { /// - /// Initializes a new + /// Initializes a new /// /// The current /// An containing the services used to validate s - protected OperationTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + protected V2OperationTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) { - this.ServiceProvider = serviceProvider; - this.Validators = validators; + ServiceProvider = serviceProvider; + Validators = validators; } /// @@ -57,7 +54,7 @@ protected OperationTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnu public virtual TBuilder WithExternalDocumentation(Uri uri, string? description = null) { ArgumentNullException.ThrowIfNull(uri); - this.Trait.ExternalDocs = new ExternalDocumentationDefinition() { Url = uri, Description = description }; + Trait.ExternalDocs = new ExternalDocumentationDefinition() { Url = uri, Description = description }; return (TBuilder)(object)this; } @@ -65,10 +62,10 @@ public virtual TBuilder WithExternalDocumentation(Uri uri, string? description = public virtual TBuilder WithTag(Action setup) { ArgumentNullException.ThrowIfNull(setup); - this.Trait.Tags ??= []; - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + Trait.Tags ??= []; + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); - this.Trait.Tags.Add(builder.Build()); + Trait.Tags.Add(builder.Build()); return (TBuilder)(object)this; } @@ -76,38 +73,51 @@ public virtual TBuilder WithTag(Action setup) public virtual TBuilder WithBinding(IOperationBindingDefinition binding) { ArgumentNullException.ThrowIfNull(binding); - this.Trait.Bindings ??= new(); - this.Trait.Bindings.Add(binding); + Trait.Bindings ??= new(); + Trait.Bindings.Add(binding); return (TBuilder)(object)this; } /// public virtual TBuilder WithDescription(string? description) { - this.Trait.Description = description; + Trait.Description = description; return (TBuilder)(object)this; } /// public virtual TBuilder WithOperationId(string operationId) { - this.Trait.OperationId = operationId; + Trait.OperationId = operationId; return (TBuilder)(object)this; } /// public virtual TBuilder WithSummary(string summary) { - this.Trait.Summary = summary; + Trait.Summary = summary; return (TBuilder)(object)this; } /// public virtual TTrait Build() { - var validationResults = this.Validators.Select(v => v.Validate(this.Trait)); + var validationResults = Validators.Select(v => v.Validate(Trait)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); - return this.Trait; + return Trait; } } + +/// +/// Represents the base class for all implementations +/// +/// +/// Initializes a new +/// +/// The current +/// An containing the services used to validate s +public class V2OperationTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : V2OperationTraitDefinitionBuilder(serviceProvider, validators), IV2OperationTraitDefinitionBuilder +{ +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/SecuritySchemeDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2SecuritySchemeDefinitionBuilder.cs similarity index 58% rename from src/Neuroglia.AsyncApi.FluentBuilders/SecuritySchemeDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/V2SecuritySchemeDefinitionBuilder.cs index 2520643..a1a8d6d 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/SecuritySchemeDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2SecuritySchemeDefinitionBuilder.cs @@ -11,15 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.FluentBuilders; +using Neuroglia; + +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// -/// Represents the default implementation of the interface +/// Represents the default implementation of the interface /// /// The current /// An containing the s used to validate built s -public class SecuritySchemeDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : ISecuritySchemeDefinitionBuilder +public class V2SecuritySchemeDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV2SecuritySchemeDefinitionBuilder { /// @@ -38,87 +40,87 @@ public class SecuritySchemeDefinitionBuilder(IServiceProvider serviceProvider, I protected V2SecuritySchemeDefinition SecurityScheme { get; } = new(); /// - public virtual ISecuritySchemeDefinitionBuilder WithType(SecuritySchemeType type) + public virtual IV2SecuritySchemeDefinitionBuilder WithType(SecuritySchemeType type) { - this.SecurityScheme.Type = type; + SecurityScheme.Type = type; return this; } /// - public virtual ISecuritySchemeDefinitionBuilder WithParameterName(string? parameterName) + public virtual IV2SecuritySchemeDefinitionBuilder WithParameterName(string? parameterName) { - this.SecurityScheme.Name = parameterName; + SecurityScheme.Name = parameterName; return this; } /// - public virtual ISecuritySchemeDefinitionBuilder WithDescription(string? description) + public virtual IV2SecuritySchemeDefinitionBuilder WithDescription(string? description) { - this.SecurityScheme.Description = description; + SecurityScheme.Description = description; return this; } /// - public virtual ISecuritySchemeDefinitionBuilder WithApiKeyLocation(string? location) + public virtual IV2SecuritySchemeDefinitionBuilder WithApiKeyLocation(string? location) { - if (string.IsNullOrWhiteSpace(location)) { this.SecurityScheme.In = null; return this; } + if (string.IsNullOrWhiteSpace(location)) { SecurityScheme.In = null; return this; } - switch (this.SecurityScheme.Type) + switch (SecurityScheme.Type) { case SecuritySchemeType.ApiKey: - if (!ApiKeyLocation.GetLocations().Contains(location)) throw new ArgumentException($"The 'in' values supported when scheme type is '{EnumHelper.Stringify(this.SecurityScheme.Type)}' are: {string.Join(", ", ApiKeyLocation.GetLocations())}", nameof(location)); + if (!ApiKeyLocation.GetLocations().Contains(location)) throw new ArgumentException($"The 'in' values supported when scheme type is '{EnumHelper.Stringify(SecurityScheme.Type)}' are: {string.Join(", ", ApiKeyLocation.GetLocations())}", nameof(location)); break; case SecuritySchemeType.HttpApiKey: - if (!HttpApiKeyLocation.GetLocations().Contains(location)) throw new ArgumentException($"The 'in' values supported when scheme type is '{EnumHelper.Stringify(this.SecurityScheme.Type)}' are: {string.Join(", ", HttpApiKeyLocation.GetLocations())}", nameof(location)); + if (!HttpApiKeyLocation.GetLocations().Contains(location)) throw new ArgumentException($"The 'in' values supported when scheme type is '{EnumHelper.Stringify(SecurityScheme.Type)}' are: {string.Join(", ", HttpApiKeyLocation.GetLocations())}", nameof(location)); break; default: throw new Exception($"The API key location can only be set on schemes of type '{EnumHelper.Stringify(SecuritySchemeType.ApiKey)}' and '{EnumHelper.Stringify(SecuritySchemeType.HttpApiKey)}'"); } - this.SecurityScheme.In = location; + SecurityScheme.In = location; return this; } /// - public virtual ISecuritySchemeDefinitionBuilder WithAuthorizationScheme(string? scheme) + public virtual IV2SecuritySchemeDefinitionBuilder WithAuthorizationScheme(string? scheme) { - this.SecurityScheme.Scheme = scheme; + SecurityScheme.Scheme = scheme; return this; } /// - public virtual ISecuritySchemeDefinitionBuilder WithBearerFormat(string? format) + public virtual IV2SecuritySchemeDefinitionBuilder WithBearerFormat(string? format) { - this.SecurityScheme.BearerFormat = format; + SecurityScheme.BearerFormat = format; return this; } /// - public virtual ISecuritySchemeDefinitionBuilder WithOAuthFlows(Action setup) + public virtual IV2SecuritySchemeDefinitionBuilder WithOAuthFlows(Action setup) { ArgumentNullException.ThrowIfNull(nameof(setup)); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); - this.SecurityScheme.Flows = builder.Build(); + SecurityScheme.Flows = builder.Build(); return this; } /// - public virtual ISecuritySchemeDefinitionBuilder WithOpenIdConnectUrl(Uri? uri) + public virtual IV2SecuritySchemeDefinitionBuilder WithOpenIdConnectUrl(Uri? uri) { - this.SecurityScheme.OpenIdConnectUrl = uri; + SecurityScheme.OpenIdConnectUrl = uri; return this; } /// public virtual V2SecuritySchemeDefinition Build() { - var validationResults = this.Validators.Select(v => v.Validate(this.SecurityScheme)); + var validationResults = Validators.Select(v => v.Validate(SecurityScheme)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); - return this.SecurityScheme; + return SecurityScheme; } } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/ServerDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ServerDefinitionBuilder.cs similarity index 59% rename from src/Neuroglia.AsyncApi.FluentBuilders/ServerDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ServerDefinitionBuilder.cs index 9b6d0c6..ecbd490 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/ServerDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ServerDefinitionBuilder.cs @@ -11,21 +11,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.Bindings; -using Neuroglia.AsyncApi.v2; +using Neuroglia.AsyncApi.FluentBuilders; -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// -/// Represents the default implementation of the +/// Represents the default implementation of the /// /// -/// Initializes a new +/// Initializes a new /// /// The current /// The services used to validate s -public class ServerDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : IServerDefinitionBuilder +public class V2ServerDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV2ServerDefinitionBuilder { /// @@ -44,64 +43,64 @@ public class ServerDefinitionBuilder(IServiceProvider serviceProvider, IEnumerab protected virtual V2ServerDefinition Server { get; } = new(); /// - public virtual IServerDefinitionBuilder WithUrl(Uri uri) + public virtual IV2ServerDefinitionBuilder WithUrl(Uri uri) { - this.Server.Url = uri ?? throw new ArgumentNullException(nameof(uri)); + Server.Url = uri ?? throw new ArgumentNullException(nameof(uri)); return this; } /// - public virtual IServerDefinitionBuilder WithProtocol(string protocol, string? version = null) + public virtual IV2ServerDefinitionBuilder WithProtocol(string protocol, string? version = null) { if (string.IsNullOrWhiteSpace(protocol)) throw new ArgumentNullException(nameof(protocol)); - this.Server.Protocol = protocol; - this.Server.ProtocolVersion = string.IsNullOrWhiteSpace(version) ? "latest" : version; + Server.Protocol = protocol; + Server.ProtocolVersion = string.IsNullOrWhiteSpace(version) ? "latest" : version; return this; } /// - public virtual IServerDefinitionBuilder WithDescription(string? description) + public virtual IV2ServerDefinitionBuilder WithDescription(string? description) { - this.Server.Description = description; + Server.Description = description; return this; } /// - public virtual IServerDefinitionBuilder WithVariable(string name, Action setup) + public virtual IV2ServerDefinitionBuilder WithVariable(string name, Action setup) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); - this.Server.Variables ??= []; - this.Server.Variables.Add(name, builder.Build()); + Server.Variables ??= []; + Server.Variables.Add(name, builder.Build()); return this; } /// - public virtual IServerDefinitionBuilder WithBinding(IServerBindingDefinition binding) + public virtual IV2ServerDefinitionBuilder WithBinding(IServerBindingDefinition binding) { ArgumentNullException.ThrowIfNull(binding); - this.Server.Bindings ??= new(); - this.Server.Bindings.Add(binding); + Server.Bindings ??= new(); + Server.Bindings.Add(binding); return this; } /// - public virtual IServerDefinitionBuilder WithSecurityRequirement(string name, object? requirement = null) + public virtual IV2ServerDefinitionBuilder WithSecurityRequirement(string name, object? requirement = null) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); requirement ??= new { }; - this.Server.Security ??= []; - this.Server.Security.Add(name, requirement); + Server.Security ??= []; + Server.Security.Add(name, requirement); return this; } /// public virtual V2ServerDefinition Build() { - var validationResults = this.Validators.Select(v => v.Validate(this.Server)); + var validationResults = Validators.Select(v => v.Validate(Server)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); - return this.Server; + return Server; } } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3AsyncApiDocumentBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3AsyncApiDocumentBuilder.cs new file mode 100644 index 0000000..525c462 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3AsyncApiDocumentBuilder.cs @@ -0,0 +1,284 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3AsyncApiDocumentBuilder +{ + + /// + /// Configures the to use the specified Async Api Specification version + /// + /// The Async Api Specification version to use + /// The configured + IV3AsyncApiDocumentBuilder WithSpecVersion(string version); + + /// + /// Configures the to use the specified id + /// + /// The id of the Async Api document to build + /// The configured + IV3AsyncApiDocumentBuilder WithId(string? id); + + /// + /// Configures the to use the specified API title + /// + /// The title of the Async Api document to build + /// The configured + IV3AsyncApiDocumentBuilder WithTitle(string title); + + /// + /// Configures the to use the specified API version + /// + /// The version of the Async Api document to build + /// The configured + IV3AsyncApiDocumentBuilder WithVersion(string version); + + /// + /// Configures the to use the specified API description + /// + /// The description of the Async Api document to build + /// The configured + IV3AsyncApiDocumentBuilder WithDescription(string? description); + + /// + /// Configures the to use the specified for the API's terms of service + /// + /// The of the API's terms of service + /// The configured + IV3AsyncApiDocumentBuilder WithTermsOfService(Uri? uri); + + /// + /// Configures the to use the specified contact for the API + /// + /// The contact name + /// The contact + /// The contact email + /// The configured + IV3AsyncApiDocumentBuilder WithContact(string name, Uri? uri = null, string? email = null); + + /// + /// Configures the to use the specified license + /// + /// The name of the license to use + /// The license's + /// The configured + IV3AsyncApiDocumentBuilder WithLicense(string name, Uri? uri = null); + + /// + /// Configures the to use the specified default content type + /// + /// The content type to use by default + /// The configured + IV3AsyncApiDocumentBuilder WithDefaultContentType(string contentType); + + /// + /// Marks the to build with the specified tag + /// + /// An used to setup the tag to use + /// The configured + IV3AsyncApiDocumentBuilder WithTag(Action setup); + + /// + /// Marks the to use the specified external documentation + /// + /// An used to setup the external documentation to use + /// The configured + IV3AsyncApiDocumentBuilder WithExternalDocumentation(Action setup); + + /// + /// Adds the specified to the to build + /// + /// The name of the to add + /// An used to setup the to add + /// The configured + IV3AsyncApiDocumentBuilder WithServer(string name, Action setup); + + /// + /// Adds the specified to the to build + /// + /// The name of the to add + /// An used to setup the to add + /// The configured + IV3AsyncApiDocumentBuilder WithChannel(string name, Action setup); + + /// + /// Adds the specified to the to build + /// + /// The name of the to add + /// An used to setup the to add + /// The configured + IV3AsyncApiDocumentBuilder WithOperation(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithSchemaComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithServerComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithChannelComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithOperationComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithMessageComponent(string name, Action setup); + + /// + /// Adds the specified reusable + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithSecuritySchemeComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithServerVariableComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithParameterComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithCorrelationIdComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithReplyComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithReplyAddressComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithExternalDocumentationComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithTagComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithOperationTraitComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithMessageTraitComponent(string name, Action setup); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// The reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithServerBindingsComponent(string name, ServerBindingDefinitionCollection bindings); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// The reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithChannelBindingsComponent(string name, ChannelBindingDefinitionCollection bindings); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// The reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithOperationBindingsComponent(string name, OperationBindingDefinitionCollection bindings); + + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// The reusable to add + /// The configured + IV3AsyncApiDocumentBuilder WithMessageBindingsComponent(string name, MessageBindingDefinitionCollection bindings); + + /// + /// Builds the configured + /// + /// A new + V3AsyncApiDocument Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs new file mode 100644 index 0000000..eaa4026 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs @@ -0,0 +1,101 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3ChannelDefinitionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to use the specified address + /// + /// The address to use + /// The configured + IV3ChannelDefinitionBuilder WithAddress(string? address); + + /// + /// Configures the to use the specified + /// + /// The name of the to use + /// An used to configure the to use + /// The configured + IV3ChannelDefinitionBuilder WithMessage(string name, Action setup); + + /// + /// Configures the to use the specified title + /// + /// The title to use + /// The configured + IV3ChannelDefinitionBuilder WithTitle(string? title); + + /// + /// Configures the to use the specified summary + /// + /// The summary to use + /// The configured + IV3ChannelDefinitionBuilder WithSummary(string? summary); + + /// + /// Configures the to use the specified description + /// + /// The description to use + /// The configured + IV3ChannelDefinitionBuilder WithDescription(string? description); + + /// + /// Configures the to use the specified + /// + /// A reference to the to use + /// The configured + IV3ChannelDefinitionBuilder WithServer(string server); + + /// + /// Configures the to use the specified + /// + /// The name of the to use + /// An used to configure the to use + /// The configured + IV3ChannelDefinitionBuilder WithParameter(string name, Action setup); + + /// + /// Marks the to build with the specified tag + /// + /// An used to setup the tag to use + /// The configured + IV3ChannelDefinitionBuilder WithTag(Action setup); + + /// + /// Marks the to use the specified external documentation + /// + /// An used to setup the external documentation to use + /// The configured + IV3ChannelDefinitionBuilder WithExternalDocumentation(Action setup); + + /// + /// Configures the to use the specified binding + /// + /// The to add + /// The configured + IV3ChannelDefinitionBuilder WithBinding(IChannelBindingDefinition binding); + + /// + /// Builds the configured + /// + /// A new + V3ChannelDefinition Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageDefinitionBuilder.cs new file mode 100644 index 0000000..bf42416 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageDefinitionBuilder.cs @@ -0,0 +1,37 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3MessageDefinitionBuilder + : IV3MessageTraitDefinitionBuilder +{ + + /// + /// Configures the to use the specified payload schema + /// + /// An used to setup the payload schema to use + /// The configured + IV3MessageDefinitionBuilder WithPayloadSchema(Action setup); + + /// + /// Configures the to build to use the specified + /// + /// An used to setup the to use + /// The configured + IV3MessageDefinitionBuilder WithTrait(Action setup); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageExampleDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageExampleDefinitionBuilder.cs new file mode 100644 index 0000000..f36d368 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageExampleDefinitionBuilder.cs @@ -0,0 +1,64 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3MessageExampleDefinitionBuilder +{ + + /// + /// Configures the to use the specified header + /// + /// The name of the header to add + /// The value of the header to add + /// The configured + IV3MessageExampleDefinitionBuilder WithHeader(string name, object value); + + /// + /// Configures the to use the specified headers + /// + /// A key/value map of the headers to use + /// The configured + IV3MessageExampleDefinitionBuilder WithHeaders(IDictionary? headers); + + /// + /// Configures the to use the specified payload + /// + /// A key/value map of the payload properties to use + /// The configured + IV3MessageExampleDefinitionBuilder WithPayload(IDictionary? payload); + + /// + /// Configures the to build to use the specified name + /// + /// The name to use + /// The configured + IV3MessageExampleDefinitionBuilder WithName(string? name); + + /// + /// Configures the to build to use the specified summary + /// + /// The summary to use + /// The configured + IV3MessageExampleDefinitionBuilder WithSummary(string? summary); + + /// + /// Builds the configured + /// + /// A new + V3MessageExampleDefinition Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageTraitDefinitionBuilder.cs new file mode 100644 index 0000000..f703b0a --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageTraitDefinitionBuilder.cs @@ -0,0 +1,121 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +/// The type of to return for chaining purposes +/// The type of to build +public interface IV3MessageTraitDefinitionBuilder + : IReferenceableComponentDefinitionBuilder + where TBuilder : IV3MessageTraitDefinitionBuilder + where TTrait : V3MessageTraitDefinition +{ + + /// + /// Configures the to use the specified headers schema + /// + /// An used to setup the to use + /// The configured + TBuilder WithHeadersSchema(Action setup); + + /// + /// Configures the to use the specified correlation id + /// + /// An used to configure the correlation id to use + /// The configured + TBuilder WithCorrelationId(Action setup); + + /// + /// Configures the to build to use the specified content type + /// + /// The content type to use + /// The configured + TBuilder WithContentType(string? contentType); + + /// + /// Configures the to build to use the specified content type + /// + /// The name to use + /// The configured + TBuilder WithName(string? name); + + /// + /// Configures the to build to use the specified title + /// + /// The title to use + /// The configured + TBuilder WithTitle(string? title); + + /// + /// Configures the to build to use the specified summary + /// + /// The summary to use + /// The configured + TBuilder WithSummary(string? summary); + + /// + /// Configures the to build to use the specified description + /// + /// The description to use + /// The configured + TBuilder WithDescription(string? description); + + /// + /// Marks the to build with the specified tag + /// + /// An used to setup the tag to use + /// The configured + TBuilder WithTag(Action setup); + + /// + /// Adds the specified external documentation to the to build + /// + /// An used to setup the to use + /// The configured + TBuilder WithExternalDocumentation(Action setup); + + /// + /// Adds the specified to the to build + /// + /// The to add + /// The configured + TBuilder WithBinding(IMessageBindingDefinition binding); + + /// + /// Adds the specified example to the to build + /// + /// An used to setup the example to add + /// The configured + TBuilder WithExample(Action setup); + + /// + /// Builds the configured + /// + /// A new + TTrait Build(); + +} + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3MessageTraitDefinitionBuilder + : IV3MessageTraitDefinitionBuilder +{ + + + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationDefinitionBuilder.cs new file mode 100644 index 0000000..38bc78b --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationDefinitionBuilder.cs @@ -0,0 +1,64 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3OperationDefinitionBuilder + : IV3OperationTraitDefinitionBuilder, IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to use the specified action + /// + /// The action to use + /// The configured + IV3OperationDefinitionBuilder WithAction(V3OperationAction action); + + /// + /// Configures the to use the specified + /// + /// A reference to the to use + /// The configured + IV3OperationDefinitionBuilder WithChannel(string channel); + + /// + /// Configures the to use the specified + /// + /// An used to build the to use + /// The configured + IV3OperationDefinitionBuilder WithTrait(Action setup); + + /// + /// Configures the to use the specified + /// + /// A reference to the the to use + /// The configured + IV3OperationDefinitionBuilder WithMessage(string message); + + /// + /// Configures the to use the specified + /// + /// An used to setup the to use + /// The configured + IV3OperationDefinitionBuilder WithReply(Action setup); + + /// + /// Builds the configured + /// + /// A new + V3OperationDefinition Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationReplyAddressDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationReplyAddressDefinitionBuilder.cs new file mode 100644 index 0000000..46ac80e --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationReplyAddressDefinitionBuilder.cs @@ -0,0 +1,43 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3OperationReplyAddressDefinitionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to use the specified description + /// + /// The description to use + /// The configured + IV3OperationReplyAddressDefinitionBuilder WithDescription(string? description); + + /// + /// Configures the to use the specified location + /// + /// The location to use + /// The configured + IV3OperationReplyAddressDefinitionBuilder WithLocation(string location); + + /// + /// Builds the configured + /// + /// A new + V3OperationReplyAddressDefinition Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationReplyDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationReplyDefinitionBuilder.cs new file mode 100644 index 0000000..e113686 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationReplyDefinitionBuilder.cs @@ -0,0 +1,50 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3OperationReplyDefinitionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to use the specified + /// + /// An used to setup the to use + /// The configured + IV3OperationReplyDefinitionBuilder WithAddress(Action setup); + + /// + /// Configures the to use the specified + /// + /// A reference to the to use + /// The configured + IV3OperationReplyDefinitionBuilder WithAddress(string channel); + + /// + /// Configures the to use the specified + /// + /// A reference to the to use + /// The configured + IV3OperationReplyDefinitionBuilder WithMessage(string message); + + /// + /// Builds the configured + /// + /// A new + V3OperationReplyDefinition Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationTraitDefinitionBuilder.cs new file mode 100644 index 0000000..372a5b7 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationTraitDefinitionBuilder.cs @@ -0,0 +1,93 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +/// The type of to return for chaining purposes +/// The type of to build +public interface IV3OperationTraitDefinitionBuilder + : IReferenceableComponentDefinitionBuilder + where TBuilder : IV3OperationTraitDefinitionBuilder + where TTrait : V3OperationTraitDefinition +{ + + /// + /// Configures the to use the specified title + /// + /// The title to use + /// The configured + TBuilder WithTitle(string? title); + + /// + /// Configures the to use the specified API description + /// + /// The summary of the Async Api document to build + /// The configured + TBuilder WithSummary(string? summary); + + /// + /// Configures the to use the specified API description + /// + /// The description of the Async Api document to build + /// The configured + TBuilder WithDescription(string? description); + + /// + /// Configures the to use the specified + /// + /// An used to setup the to use + /// The configured + TBuilder WithSecurity(Action setup); + + /// + /// Marks the to build with the specified tag + /// + /// An used to setup the tag to use + /// The configured + TBuilder WithTag(Action setup); + + /// + /// Adds the specified external documentation to the to build + /// + /// An used to setup the to use + /// The configured + TBuilder WithExternalDocumentation(Action setup); + + /// + /// Adds the specified to the to build + /// + /// The to add + /// The configured + TBuilder WithBinding(IOperationBindingDefinition binding); + + /// + /// Builds a new + /// + /// A new + TTrait Build(); + +} + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3OperationTraitDefinitionBuilder + : IV3OperationTraitDefinitionBuilder +{ + + + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ParameterDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ParameterDefinitionBuilder.cs new file mode 100644 index 0000000..830b170 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ParameterDefinitionBuilder.cs @@ -0,0 +1,64 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3ParameterDefinitionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to use the specified enum values + /// + /// The enum values to use + /// The configured + IV3ParameterDefinitionBuilder WithEnumValues(params string[]? values); + + /// + /// Configures the to use the specified default value + /// + /// The default value to use + /// The configured + IV3ParameterDefinitionBuilder WithDefaultValue(string? value); + + /// + /// Configures the to use the specified description + /// + /// The description to use + /// The configured + IV3ParameterDefinitionBuilder WithDescription(string? description); + + /// + /// Configures the to use the specified example + /// + /// The example to use + /// The configured + IV3ParameterDefinitionBuilder WithExample(string example); + + /// + /// Configures the to use the specified location + /// + /// The location to use + /// The configured + IV3ParameterDefinitionBuilder WithLocation(string location); + + /// + /// Builds the configured + /// + /// A new + V3ParameterDefinition Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3SchemaDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3SchemaDefinitionBuilder.cs new file mode 100644 index 0000000..62b080c --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3SchemaDefinitionBuilder.cs @@ -0,0 +1,43 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3SchemaDefinitionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to use the specified schema + /// + /// The schema to use + /// The configured + IV3SchemaDefinitionBuilder WithSchema(object schema); + + /// + /// Configures the to use the specified format + /// + /// The format to use + /// The configured + IV3SchemaDefinitionBuilder WithFormat(string format); + + /// + /// Builds the configured + /// + /// A new + V3SchemaDefinition Build(); + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3SecuritySchemeDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3SecuritySchemeDefinitionBuilder.cs new file mode 100644 index 0000000..c617ee2 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3SecuritySchemeDefinitionBuilder.cs @@ -0,0 +1,92 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3SecuritySchemeDefinitionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to build to be of the specified + /// + /// The of the to build + /// The configured + IV3SecuritySchemeDefinitionBuilder WithType(SecuritySchemeType type); + + /// + /// Configures the to build to use the specified name + /// + /// The 's name + /// The configured + IV3SecuritySchemeDefinitionBuilder WithParameterName(string? name); + + /// + /// Configures the to build to use the specified description + /// + /// The 's description + /// The configured + IV3SecuritySchemeDefinitionBuilder WithDescription(string? location); + + /// + /// Configures the to build to store API keys at the specified location + /// + /// The location to store the API key at + /// The configured + IV3SecuritySchemeDefinitionBuilder WithApiKeyLocation(string? location); + + /// + /// Configures the to build to use the specified scheme name in the Authorization header, as defined in RFC7235. + /// + /// The name of the authorization scheme to use + /// The configured + IV3SecuritySchemeDefinitionBuilder WithAuthorizationScheme(string? scheme); + + /// + /// Configures the to build to use the specified object hint for the client to identify how the bearer token is formatted + /// + /// The bearer format to use + /// The configured + IV3SecuritySchemeDefinitionBuilder WithBearerFormat(string? format); + + /// + /// Configures the to build to use the specified OpenId Connect to discover OAuth2 configuration values + /// + /// The OpenId Connect at which to discover OAuth2 configuration values + /// The configured + IV3SecuritySchemeDefinitionBuilder WithOpenIdConnectUrl(Uri? uri); + + /// + /// Configures the to build to use the specified OAUTH flows + /// + /// An used to build the s to use + /// The configured + IV3SecuritySchemeDefinitionBuilder WithOAuthFlows(Action setup); + + /// + /// Configures the to use the specified scope + /// + /// The scope to use + /// The configured + IV3SecuritySchemeDefinitionBuilder WithScope(string scope); + + /// + /// Builds the configured + /// + /// A new + V3SecuritySchemeDefinition Build(); + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerDefinitionBuilder.cs new file mode 100644 index 0000000..867b307 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerDefinitionBuilder.cs @@ -0,0 +1,108 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3ServerDefinitionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to use the specified host + /// + /// The host to use + /// The configured + IV3ServerDefinitionBuilder WithHost(string host); + + /// + /// Configures the to use the specified protocol + /// + /// The protocol to use + /// The protocol version to use + /// The configured + IV3ServerDefinitionBuilder WithProtocol(string protocol, string? version = null); + + /// + /// Configures the to use the specified path name + /// + /// The path name to use + /// The configured + IV3ServerDefinitionBuilder WithPathName(string pathName); + + /// + /// Configures the to use the specified description + /// + /// The description to use + /// The configured + IV3ServerDefinitionBuilder WithDescription(string? description); + + /// + /// Configures the to use the specified title + /// + /// The title to use + /// The configured + IV3ServerDefinitionBuilder WithTitle(string? title); + + /// + /// Configures the to use the specified summary + /// + /// The summary to use + /// The configured + IV3ServerDefinitionBuilder WithSummary(string? summary); + + /// + /// Adds the specified to the to build + /// + /// The name of the to add + /// An used to setup the to add + /// The configured + IV3ServerDefinitionBuilder WithVariable(string name, Action setup); + + /// + /// Configures the to use the specified + /// + /// An used to configure the to use + /// The configured + IV3ServerDefinitionBuilder WithSecurity(Action setup); + + /// + /// Marks the to build with the specified tag + /// + /// An used to setup the tag to use + /// The configured + IV3ServerDefinitionBuilder WithTag(Action setup); + + /// + /// Configures the to use the specified external documentation + /// + /// An used to setup the external documentation to use + /// The configured + IV3ServerDefinitionBuilder WithExternalDocumentation(Action setup); + + /// + /// Adds the specified to the to build + /// + /// The to add + /// The configured + IV3ServerDefinitionBuilder WithBinding(IServerBindingDefinition binding); + + /// + /// Builds the configured + /// + /// A new + V3ServerDefinition Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs new file mode 100644 index 0000000..14707b2 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs @@ -0,0 +1,569 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +using Neuroglia.AsyncApi.FluentBuilders.v2; +using System.Reflection.Metadata; + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// The services used to validate s +public class V3ChannelDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3ChannelDefinitionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected virtual V3ChannelDefinition Channel { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + Channel.Reference = reference; + } + + /// + public virtual IV3ChannelDefinitionBuilder WithAddress(string? address) + { + Channel.Address = address; + return this; + } + + /// + public virtual IV3ChannelDefinitionBuilder WithMessage(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Channel.Messages ??= []; + Channel.Messages[name] = builder.Build(); + return this; + } + + /// + public virtual IV3ChannelDefinitionBuilder WithTitle(string? title) + { + Channel.Title = title; + return this; + } + + /// + public virtual IV3ChannelDefinitionBuilder WithSummary(string? summary) + { + Channel.Summary = summary; + return this; + } + + /// + public virtual IV3ChannelDefinitionBuilder WithDescription(string? description) + { + Channel.Description = description; + return this; + } + + /// + public virtual IV3ChannelDefinitionBuilder WithServer(string server) + { + ArgumentException.ThrowIfNullOrWhiteSpace(server); + Channel.Servers ??= []; + Channel.Servers.Add(new() + { + Reference = server + }); + return this; + } + + /// + public virtual IV3ChannelDefinitionBuilder WithParameter(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Channel.Parameters ??= []; + Channel.Parameters[name] = builder.Build(); + return this; + } + + /// + public virtual IV3ChannelDefinitionBuilder WithExternalDocumentation(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Channel.ExternalDocs = builder.Build(); + return this; + } + + /// + public virtual IV3ChannelDefinitionBuilder WithTag(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Channel.Tags ??= []; + Channel.Tags.Add(builder.Build()); + return this; + } + + /// + public virtual IV3ChannelDefinitionBuilder WithBinding(IChannelBindingDefinition binding) + { + ArgumentNullException.ThrowIfNull(binding); + Channel.Bindings ??= new(); + Channel.Bindings.Add(binding); + return this; + } + + /// + public virtual V3ChannelDefinition Build() + { + var validationResults = Validators.Select(v => v.Validate(Channel)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return Channel; + } + +} + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// The services used to validate s +public class V3AsyncApiDocumentBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3AsyncApiDocumentBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected virtual V3AsyncApiDocument Document { get; } = new(); + + /// + public virtual IV3AsyncApiDocumentBuilder WithSpecVersion(string version) + { + ArgumentException.ThrowIfNullOrWhiteSpace(version); + Document.AsyncApi = version; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithId(string? id) + { + Document.Id = id; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithTitle(string title) + { + ArgumentException.ThrowIfNullOrWhiteSpace(title); + Document.Info ??= new(); + Document.Info.Title = title; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithVersion(string version) + { + ArgumentException.ThrowIfNullOrWhiteSpace(version); + Document.Info ??= new(); + Document.Info.Version = version; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithDescription(string? description) + { + Document.Info ??= new(); + Document.Info.Description = description; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithTermsOfService(Uri? uri) + { + Document.Info ??= new(); + Document.Info.TermsOfService = uri; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithContact(string name, Uri? uri = null, string? email = null) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + Document.Info ??= new(); + Document.Info.Contact = new() + { + Name = name, + Url = uri, + Email = email + }; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithLicense(string name, Uri? uri = null) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + Document.Info ??= new(); + Document.Info.License = new() + { + Name = name, + Url = uri + }; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithDefaultContentType(string contentType) + { + ArgumentException.ThrowIfNullOrEmpty(contentType); + Document.DefaultContentType = contentType; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithTag(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Info ??= new(); + Document.Info.Tags ??= []; + Document.Info.Tags.Add(builder.Build()); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithExternalDocumentation(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Info ??= new(); + Document.Info.ExternalDocs = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithServer(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Servers ??= []; + Document.Servers[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithChannel(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Channels ??= []; + Document.Channels[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithOperation(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Operations ??= []; + Document.Operations[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithSchemaComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Schemas ??= []; + Document.Components.Schemas[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithServerComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Servers ??= []; + Document.Components.Servers[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithChannelComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Channels ??= []; + Document.Components.Channels[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithOperationComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Operations ??= []; + Document.Components.Operations[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithMessageComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Messages ??= []; + Document.Components.Messages[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithSecuritySchemeComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.SecuritySchemes ??= []; + Document.Components.SecuritySchemes[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithServerVariableComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.ServerVariables ??= []; + Document.Components.ServerVariables[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithParameterComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Parameters ??= []; + Document.Components.Parameters[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithCorrelationIdComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.CorrelationIds ??= []; + Document.Components.CorrelationIds[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithReplyComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Replies ??= []; + Document.Components.Replies[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithReplyAddressComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.ReplyAddresses ??= []; + Document.Components.ReplyAddresses[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithExternalDocumentationComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.ExternalDocs ??= []; + Document.Components.ExternalDocs[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithTagComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Tags ??= []; + Document.Components.Tags[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithOperationTraitComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.OperationTraits ??= []; + Document.Components.OperationTraits[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithMessageTraitComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.MessageTraits ??= []; + Document.Components.MessageTraits[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithServerBindingsComponent(string name, ServerBindingDefinitionCollection bindings) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(bindings); + Document.Components ??= new(); + Document.Components.ServerBindings ??= []; + Document.Components.ServerBindings[name] = bindings; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithChannelBindingsComponent(string name, ChannelBindingDefinitionCollection bindings) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(bindings); + Document.Components ??= new(); + Document.Components.ChannelBindings ??= []; + Document.Components.ChannelBindings[name] = bindings; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithOperationBindingsComponent(string name, OperationBindingDefinitionCollection bindings) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(bindings); + Document.Components ??= new(); + Document.Components.OperationBindings ??= []; + Document.Components.OperationBindings[name] = bindings; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithMessageBindingsComponent(string name, MessageBindingDefinitionCollection bindings) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(bindings); + Document.Components ??= new(); + Document.Components.MessageBindings ??= []; + Document.Components.MessageBindings[name] = bindings; + return this; + } + + /// + public virtual V3AsyncApiDocument Build() + { + var validationResults = Validators.Select(v => v.Validate(Document)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return Document; + } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageDefinitionBuilder.cs new file mode 100644 index 0000000..cde32bc --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageDefinitionBuilder.cs @@ -0,0 +1,46 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// The services used to validate s +public class V3MessageDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : V3MessageTraitDefinitionBuilder(serviceProvider, validators), IV3MessageDefinitionBuilder +{ + + /// + public virtual IV3MessageDefinitionBuilder WithPayloadSchema(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Trait.Payload = builder.Build(); + return this; + } + + /// + public virtual IV3MessageDefinitionBuilder WithTrait(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Trait.Traits ??= []; + Trait.Traits.Add(builder.Build()); + return this; + } + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageExampleDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageExampleDefinitionBuilder.cs new file mode 100644 index 0000000..c7de346 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageExampleDefinitionBuilder.cs @@ -0,0 +1,86 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the base class for all implementations +/// +/// The current +/// The services used to validate s +public class V3MessageExampleDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3MessageExampleDefinitionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected V3MessageExampleDefinition MessageExample { get; } = new(); + + /// + public virtual IV3MessageExampleDefinitionBuilder WithHeader(string name, object value) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(value); + MessageExample.Headers ??= []; + MessageExample.Headers[name] = value; + return this; + } + + /// + public virtual IV3MessageExampleDefinitionBuilder WithHeaders(IDictionary? headers) + { + MessageExample.Headers = headers == null ? null : new(headers); + return this; + } + + /// + public virtual IV3MessageExampleDefinitionBuilder WithPayload(IDictionary? payload) + { + MessageExample.Payload = payload == null ? null : new(payload); + return this; + } + + /// + public virtual IV3MessageExampleDefinitionBuilder WithName(string? name) + { + MessageExample.Name = name; + return this; + } + + /// + public virtual IV3MessageExampleDefinitionBuilder WithSummary(string? summary) + { + MessageExample.Summary = summary; + return this; + } + + /// + public virtual V3MessageExampleDefinition Build() + { + var validationResults = Validators.Select(v => v.Validate(MessageExample)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return MessageExample; + } + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageTraitDefinitionBuilder.cs new file mode 100644 index 0000000..8e654c0 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageTraitDefinitionBuilder.cs @@ -0,0 +1,166 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the base class for all implementations +/// +/// The type of to return for chaining purposes +/// The type of to build +/// The current +/// The services used to validate s +public abstract class V3MessageTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3MessageTraitDefinitionBuilder + where TBuilder : IV3MessageTraitDefinitionBuilder + where TTrait : V3MessageTraitDefinition, new() +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected TTrait Trait { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + Trait.Reference = reference; + } + + /// + public virtual TBuilder WithHeadersSchema(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Trait.Headers = builder.Build(); + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithCorrelationId(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Trait.CorrelationId = builder.Build(); + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithContentType(string? contentType) + { + Trait.ContentType = contentType; + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithName(string? name) + { + Trait.Name = name; + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithTitle(string? title) + { + Trait.Title = title; + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithSummary(string? summary) + { + Trait.Summary = summary; + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithDescription(string? description) + { + Trait.Description = description; + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithTag(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Trait.Tags ??= []; + Trait.Tags.Add(builder.Build()); + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithExternalDocumentation(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Trait.ExternalDocs = builder.Build(); + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithBinding(IMessageBindingDefinition binding) + { + ArgumentNullException.ThrowIfNull(binding); + Trait.Bindings ??= new(); + Trait.Bindings.Add(binding); + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithExample(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Trait.Examples ??= []; + Trait.Examples.Add(builder.Build()); + return (TBuilder)(object)this; + } + + /// + public virtual TTrait Build() + { + var validationResults = Validators.Select(v => v.Validate(Trait)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return Trait; + } + +} + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// An containing the services used to validate s +public class V3MessageTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : V3MessageTraitDefinitionBuilder(serviceProvider, validators), IV3MessageTraitDefinitionBuilder +{ + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationDefinitionBuilder.cs new file mode 100644 index 0000000..9319f31 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationDefinitionBuilder.cs @@ -0,0 +1,76 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// The services used to validate s +public class V3OperationDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : V3OperationTraitDefinitionBuilder(serviceProvider, validators), IV3OperationDefinitionBuilder +{ + + /// + public virtual IV3OperationDefinitionBuilder WithAction(V3OperationAction action) + { + Trait.Action = action; + return this; + } + + /// + public virtual IV3OperationDefinitionBuilder WithChannel(string channel) + { + ArgumentException.ThrowIfNullOrWhiteSpace(channel); + Trait.Channel = new() + { + Reference = channel + }; + return this; + } + + /// + public virtual IV3OperationDefinitionBuilder WithMessage(string message) + { + ArgumentException.ThrowIfNullOrWhiteSpace(message); + Trait.Messages ??= []; + Trait.Messages.Add(new() + { + Reference = message + }); + return this; + } + + /// + public virtual IV3OperationDefinitionBuilder WithReply(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Trait.Reply = builder.Build(); + return this; + } + + /// + public virtual IV3OperationDefinitionBuilder WithTrait(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Trait.Traits ??= []; + Trait.Traits.Add(builder.Build()); + return this; + } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationReplyAddressDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationReplyAddressDefinitionBuilder.cs new file mode 100644 index 0000000..cfb29dd --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationReplyAddressDefinitionBuilder.cs @@ -0,0 +1,70 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// The services used to validate s +public class V3OperationReplyAddressDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3OperationReplyAddressDefinitionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected virtual V3OperationReplyAddressDefinition ReplyAddress { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + ReplyAddress.Reference = reference; + } + + /// + public virtual IV3OperationReplyAddressDefinitionBuilder WithDescription(string? description) + { + ReplyAddress.Description = description; + return this; + } + + /// + public virtual IV3OperationReplyAddressDefinitionBuilder WithLocation(string location) + { + ArgumentException.ThrowIfNullOrWhiteSpace(location); + ReplyAddress.Location = location; + return this; + } + + /// + public virtual V3OperationReplyAddressDefinition Build() + { + var validationResults = Validators.Select(v => v.Validate(ReplyAddress)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return ReplyAddress; + } + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationReplyDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationReplyDefinitionBuilder.cs new file mode 100644 index 0000000..4c203da --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationReplyDefinitionBuilder.cs @@ -0,0 +1,88 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// The services used to validate s +public class V3OperationReplyDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3OperationReplyDefinitionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected virtual V3OperationReplyDefinition Reply { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + Reply.Reference = reference; + } + + /// + public virtual IV3OperationReplyDefinitionBuilder WithAddress(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Reply.Address = builder.Build(); + return this; + } + + /// + public virtual IV3OperationReplyDefinitionBuilder WithAddress(string channel) + { + ArgumentException.ThrowIfNullOrWhiteSpace(channel); + Reply.Channel = new() + { + Reference = channel + }; + return this; + } + + /// + public virtual IV3OperationReplyDefinitionBuilder WithMessage(string message) + { + ArgumentException.ThrowIfNullOrWhiteSpace(message); + Reply.Messages ??= []; + Reply.Messages.Add(new() + { + Reference = message + }); + return this; + } + + /// + public virtual V3OperationReplyDefinition Build() + { + var validationResults = Validators.Select(v => v.Validate(Reply)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return Reply; + } + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationTraitDefinitionBuilder.cs new file mode 100644 index 0000000..15ed7f0 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationTraitDefinitionBuilder.cs @@ -0,0 +1,135 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the base class for all implementations +/// +/// The type of to return for chaining purposes +/// The type of to build +/// The current +/// An containing the services used to validate s +public abstract class V3OperationTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3OperationTraitDefinitionBuilder + where TBuilder : IV3OperationTraitDefinitionBuilder + where TTrait : V3OperationTraitDefinition, new() +{ + + /// + /// Gets the current + /// + protected IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets an containing the services used to validate s + /// + protected IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected virtual TTrait Trait { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + Trait.Reference = reference; + } + + /// + public virtual TBuilder WithTitle(string? title) + { + Trait.Title = title; + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithSummary(string? summary) + { + Trait.Summary = summary; + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithDescription(string? description) + { + Trait.Description = description; + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithSecurity(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + setup(builder); + Trait.Security ??= []; + Trait.Security.Add(builder.Build()); + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithTag(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + setup(builder); + Trait.Tags ??= []; + Trait.Tags.Add(builder.Build()); + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithExternalDocumentation(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + setup(builder); + Trait.ExternalDocs = builder.Build(); + return (TBuilder)(object)this; + } + + /// + public virtual TBuilder WithBinding(IOperationBindingDefinition binding) + { + ArgumentNullException.ThrowIfNull(binding); + Trait.Bindings ??= new(); + Trait.Bindings.Add(binding); + return (TBuilder)(object)this; + } + + /// + public virtual TTrait Build() + { + var validationResults = Validators.Select(v => v.Validate(Trait)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return Trait; + } + +} + +/// +/// Represents the base class for all implementations +/// +/// +/// Initializes a new +/// +/// The current +/// An containing the services used to validate s +public class V3OperationTraitDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : V3OperationTraitDefinitionBuilder(serviceProvider, validators), IV3OperationTraitDefinitionBuilder +{ + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ParameterDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ParameterDefinitionBuilder.cs new file mode 100644 index 0000000..928acf5 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ParameterDefinitionBuilder.cs @@ -0,0 +1,93 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// The services used to validate s +public class V3ParameterDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3ParameterDefinitionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected V3ParameterDefinition Parameter { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + Parameter.Reference = reference; + } + + /// + public virtual IV3ParameterDefinitionBuilder WithEnumValues(params string[]? values) + { + Parameter.Enum = values == null ? null : new(values); + return this; + } + + /// + public virtual IV3ParameterDefinitionBuilder WithDefaultValue(string? value) + { + Parameter.Default = value; + return this; + } + + /// + public virtual IV3ParameterDefinitionBuilder WithDescription(string? description) + { + Parameter.Description = description; + return this; + } + + /// + public virtual IV3ParameterDefinitionBuilder WithExample(string example) + { + ArgumentException.ThrowIfNullOrWhiteSpace(example); + Parameter.Examples ??= []; + Parameter.Examples.Add(example); + return this; + } + + /// + public virtual IV3ParameterDefinitionBuilder WithLocation(string location) + { + ArgumentException.ThrowIfNullOrWhiteSpace(location); + Parameter.Location = location; + return this; + } + + /// + public virtual V3ParameterDefinition Build() + { + var validationResults = Validators.Select(v => v.Validate(Parameter)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return Parameter; + } + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SchemaDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SchemaDefinitionBuilder.cs new file mode 100644 index 0000000..5330b90 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SchemaDefinitionBuilder.cs @@ -0,0 +1,71 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// The services used to validate s +public class V3SchemaDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3SchemaDefinitionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected V3SchemaDefinition Schema { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + Schema.Reference = reference; + } + + /// + public virtual IV3SchemaDefinitionBuilder WithFormat(string format) + { + ArgumentException.ThrowIfNullOrWhiteSpace(format); + Schema.SchemaFormat = format; + return this; + } + + /// + public virtual IV3SchemaDefinitionBuilder WithSchema(object schema) + { + ArgumentNullException.ThrowIfNull(schema); + Schema.Schema = schema; + return this; + } + + /// + public virtual V3SchemaDefinition Build() + { + var validationResults = Validators.Select(v => v.Validate(Schema)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return Schema; + } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SecuritySchemeDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SecuritySchemeDefinitionBuilder.cs new file mode 100644 index 0000000..f65e0cf --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SecuritySchemeDefinitionBuilder.cs @@ -0,0 +1,135 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// The services used to validate s +public class V3SecuritySchemeDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3SecuritySchemeDefinitionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected virtual V3SecuritySchemeDefinition SecurityScheme { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + SecurityScheme.Reference = reference; + } + + /// + public virtual IV3SecuritySchemeDefinitionBuilder WithType(SecuritySchemeType type) + { + SecurityScheme.Type = type; + return this; + } + + /// + public virtual IV3SecuritySchemeDefinitionBuilder WithParameterName(string? parameterName) + { + SecurityScheme.Name = parameterName; + return this; + } + + /// + public virtual IV3SecuritySchemeDefinitionBuilder WithDescription(string? description) + { + SecurityScheme.Description = description; + return this; + } + + /// + public virtual IV3SecuritySchemeDefinitionBuilder WithApiKeyLocation(string? location) + { + if (string.IsNullOrWhiteSpace(location)) { SecurityScheme.In = null; return this; } + switch (SecurityScheme.Type) + { + case SecuritySchemeType.ApiKey: + if (!ApiKeyLocation.GetLocations().Contains(location)) throw new ArgumentException($"The 'in' values supported when scheme type is '{EnumHelper.Stringify(SecurityScheme.Type)}' are: {string.Join(", ", ApiKeyLocation.GetLocations())}", nameof(location)); + break; + case SecuritySchemeType.HttpApiKey: + if (!HttpApiKeyLocation.GetLocations().Contains(location)) throw new ArgumentException($"The 'in' values supported when scheme type is '{EnumHelper.Stringify(SecurityScheme.Type)}' are: {string.Join(", ", HttpApiKeyLocation.GetLocations())}", nameof(location)); + + break; + default: throw new Exception($"The API key location can only be set on schemes of type '{EnumHelper.Stringify(SecuritySchemeType.ApiKey)}' and '{EnumHelper.Stringify(SecuritySchemeType.HttpApiKey)}'"); + } + SecurityScheme.In = location; + return this; + } + + /// + public virtual IV3SecuritySchemeDefinitionBuilder WithAuthorizationScheme(string? scheme) + { + SecurityScheme.Scheme = scheme; + return this; + } + + /// + public virtual IV3SecuritySchemeDefinitionBuilder WithBearerFormat(string? format) + { + SecurityScheme.BearerFormat = format; + return this; + } + + /// + public virtual IV3SecuritySchemeDefinitionBuilder WithOAuthFlows(Action setup) + { + ArgumentNullException.ThrowIfNull(nameof(setup)); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + setup(builder); + SecurityScheme.Flows = builder.Build(); + return this; + } + + /// + public virtual IV3SecuritySchemeDefinitionBuilder WithOpenIdConnectUrl(Uri? uri) + { + SecurityScheme.OpenIdConnectUrl = uri; + return this; + } + + /// + public virtual IV3SecuritySchemeDefinitionBuilder WithScope(string scope) + { + ArgumentException.ThrowIfNullOrWhiteSpace(scope); + SecurityScheme.Scopes ??= []; + SecurityScheme.Scopes.Add(scope); + return this; + } + + /// + public virtual V3SecuritySchemeDefinition Build() + { + var validationResults = Validators.Select(v => v.Validate(SecurityScheme)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return SecurityScheme; + } + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerDefinitionBuilder.cs new file mode 100644 index 0000000..f107874 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerDefinitionBuilder.cs @@ -0,0 +1,151 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// The services used to validate s +public class V3ServerDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3ServerDefinitionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected virtual V3ServerDefinition Server { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + this.Server.Reference = reference; + } + + /// + public virtual IV3ServerDefinitionBuilder WithHost(string host) + { + ArgumentException.ThrowIfNullOrWhiteSpace(host); + Server.Host = host; + return this; + } + + /// + public virtual IV3ServerDefinitionBuilder WithProtocol(string protocol, string? version = null) + { + ArgumentException.ThrowIfNullOrWhiteSpace(protocol); + Server.Protocol = protocol; + Server.ProtocolVersion = version; + return this; + } + + /// + public virtual IV3ServerDefinitionBuilder WithPathName(string? pathName) + { + Server.PathName = pathName; + return this; + } + + /// + public virtual IV3ServerDefinitionBuilder WithDescription(string? description) + { + Server.Description = description; + return this; + } + + /// + public virtual IV3ServerDefinitionBuilder WithTitle(string? title) + { + Server.Title = title; + return this; + } + + /// + public virtual IV3ServerDefinitionBuilder WithSummary(string? summary) + { + Server.Summary = summary; + return this; + } + + /// + public virtual IV3ServerDefinitionBuilder WithVariable(string name, Action setup) + { + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Server.Variables ??= []; + Server.Variables[name] = builder.Build(); + return this; + } + + /// + public virtual IV3ServerDefinitionBuilder WithExternalDocumentation(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Server.ExternalDocs = builder.Build(); + return this; + } + + /// + public virtual IV3ServerDefinitionBuilder WithTag(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Server.Tags ??= []; + Server.Tags.Add(builder.Build()); + return this; + } + + /// + public virtual IV3ServerDefinitionBuilder WithSecurity(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Server.Security ??= []; + Server.Security.Add(builder.Build()); + return this; + } + + /// + public virtual IV3ServerDefinitionBuilder WithBinding(IServerBindingDefinition binding) + { + ArgumentNullException.ThrowIfNull(binding); + Server.Bindings ??= new(); + Server.Bindings.Add(binding); + return this; + } + + /// + public virtual V3ServerDefinition Build() + { + var validationResults = Validators.Select(v => v.Validate(Server)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return Server; + } + +} diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerationOptions.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerationOptions.cs index ed071a9..c206404 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerationOptions.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerationOptions.cs @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.FluentBuilders.v2; using Neuroglia.AsyncApi.v2; namespace Neuroglia.AsyncApi.Generation; @@ -24,7 +25,7 @@ public class AsyncApiDocumentGenerationOptions /// /// Gets/sets an used to configure the s to configure /// - public Action? DefaultConfiguration { get; set; } + public Action? DefaultConfiguration { get; set; } /// /// Gets/sets a boolean indicating whether or not the automatically generate examples. Defaults to true. diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.cs index d9abab7..9e9b2df 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.cs @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.FluentBuilders.v2; using Neuroglia.Data.Schemas.Json; namespace Neuroglia.AsyncApi.Generation; @@ -64,7 +65,7 @@ protected virtual async Task GenerateDocumentForAsync(Type t ArgumentNullException.ThrowIfNull(type); var asyncApi = type.GetCustomAttribute() ?? throw new ArgumentException($"The specified type '{type.Name}' is not marked with the {nameof(AsyncApiAttribute)}", nameof(type)); - var builder = this.ServiceProvider.GetRequiredService(); + var builder = this.ServiceProvider.GetRequiredService(); options.DefaultConfiguration?.Invoke(builder); builder .WithId(asyncApi.Id!) @@ -87,13 +88,13 @@ protected virtual async Task GenerateDocumentForAsync(Type t /// /// Builds a new /// - /// The to configure + /// The to configure /// The attribute used to describe the to configure /// A containing the 's s s /// The to use /// A /// A new awaitable - protected virtual async Task ConfigureChannelForAsync(IAsyncApiDocumentBuilder builder, ChannelAttribute channel, List methods, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) + protected virtual async Task ConfigureChannelForAsync(IV2AsyncApiDocumentBuilder builder, ChannelAttribute channel, List methods, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(builder); ArgumentNullException.ThrowIfNull(channel); @@ -128,11 +129,11 @@ protected virtual async Task ConfigureChannelForAsync(IAsyncApiDocumentBuilder b /// /// Configures and builds a new for the specified /// - /// The to configure + /// The to configure /// The attribute used to describe the to configure /// The marked with the specified attribute /// The to use - protected virtual void ConfigureOperationMessageFor(IMessageDefinitionBuilder messageBuilder, OperationAttribute operation, MethodInfo operationMethod, AsyncApiDocumentGenerationOptions options) + protected virtual void ConfigureOperationMessageFor(IV2MessageDefinitionBuilder messageBuilder, OperationAttribute operation, MethodInfo operationMethod, AsyncApiDocumentGenerationOptions options) { ArgumentNullException.ThrowIfNull(messageBuilder); ArgumentNullException.ThrowIfNull(operation); diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptions.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptions.cs index fa09dc6..ebae59f 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptions.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptions.cs @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.FluentBuilders.v2; using Neuroglia.AsyncApi.v2; namespace Neuroglia.AsyncApi; @@ -29,6 +30,6 @@ public class AsyncApiGenerationOptions /// /// Gets/sets the used to apply a default configuration to generated s /// - public virtual Action? DefaultDocumentConfiguration { get; set; } + public virtual Action? DefaultDocumentConfiguration { get; set; } } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptionsBuilder.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptionsBuilder.cs index 9cf81b6..a6ba828 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptionsBuilder.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptionsBuilder.cs @@ -11,6 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.FluentBuilders.v2; + namespace Neuroglia.AsyncApi.Generation; /// @@ -48,7 +50,7 @@ public virtual IAsyncApiGenerationOptionsBuilder WithMarkupType(Type markupType) public virtual IAsyncApiGenerationOptionsBuilder WithMarkupType() => this.WithMarkupType(typeof(TMarkup)); /// - public virtual IAsyncApiGenerationOptionsBuilder UseDefaultConfiguration(Action configurationAction) + public virtual IAsyncApiGenerationOptionsBuilder UseDefaultConfiguration(Action configurationAction) { this.Options.DefaultDocumentConfiguration = configurationAction; return this; diff --git a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiGenerationOptionsBuilder.cs b/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiGenerationOptionsBuilder.cs index 36d4263..59505ed 100644 --- a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiGenerationOptionsBuilder.cs +++ b/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiGenerationOptionsBuilder.cs @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.FluentBuilders.v2; using Neuroglia.AsyncApi.v2; namespace Neuroglia.AsyncApi.Generation; @@ -38,9 +39,9 @@ public interface IAsyncApiGenerationOptionsBuilder /// /// Configures the to use the specified to setup the default configuration for generated s /// - /// The used to configure the used to build s + /// The used to configure the used to build s /// The configured - IAsyncApiGenerationOptionsBuilder UseDefaultConfiguration(Action configurationAction); + IAsyncApiGenerationOptionsBuilder UseDefaultConfiguration(Action configurationAction); /// /// Builds new diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/CloudEvents/CloudEventExtensionsTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/CloudEvents/CloudEventExtensionsTests.cs index 5940b3c..b132f56 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/CloudEvents/CloudEventExtensionsTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/CloudEvents/CloudEventExtensionsTests.cs @@ -12,6 +12,8 @@ // limitations under the License. using Neuroglia.AsyncApi.Bindings.Http; +using Neuroglia.AsyncApi.FluentBuilders.v2; +using Neuroglia.AsyncApi.FluentBuilders.v2; namespace Neuroglia.AsyncApi.UnitTests.Cases.CloudEvents; @@ -22,13 +24,13 @@ public class CloudEventExtensionsTests public CloudEventExtensionsTests() { var services = new ServiceCollection(); - services.AddSingleton(); + services.AddSingleton(); this.Services = services.BuildServiceProvider(); } ServiceProvider Services { get; } - IAsyncApiDocumentBuilder Builder => this.Services.GetRequiredService(); + IV2AsyncApiDocumentBuilder Builder => this.Services.GetRequiredService(); [Fact] public void Build_Operation_With_CloudEventMessage_Should_Work() diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs index be255ab..b472e94 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs @@ -12,6 +12,8 @@ // limitations under the License. using Neuroglia.AsyncApi.Bindings.Http; +using Neuroglia.AsyncApi.FluentBuilders.v2; +using Neuroglia.AsyncApi.FluentBuilders.v3; namespace Neuroglia.AsyncApi.UnitTests.Cases.Fluent; @@ -22,16 +24,19 @@ public class FluentBuilderTests public FluentBuilderTests() { var services = new ServiceCollection(); - services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); this.Services = services.BuildServiceProvider(); } ServiceProvider Services { get; } - IAsyncApiDocumentBuilder Builder => this.Services.GetRequiredService(); + IV2AsyncApiDocumentBuilder V2Builder => this.Services.GetRequiredService(); + + IV3AsyncApiDocumentBuilder V3Builder => this.Services.GetRequiredService(); [Fact] - public void Build_AsyncApiDocument_Should_Work() + public void Build_AsyncApiDocument_V2_Should_Work() { //arrange var specVersion = AsyncApiSpecVersion.V2; @@ -72,7 +77,7 @@ public void Build_AsyncApiDocument_Should_Work() var subscribeOperationSummary = "Fake Subscribe Operation Summary"; //act - var document = this.Builder + var document = this.V2Builder .WithSpecVersion(specVersion) .WithId(id) .WithTitle(title) @@ -191,6 +196,180 @@ public void Build_AsyncApiDocument_Should_Work() tag.ExternalDocs.Url.Should().Be(tagDocumentationUri); } + [Fact] + public void Build_AsyncApiDocument_V3_Should_Work() + { + //arrange + var specVersion = AsyncApiSpecVersion.V2; + var id = "fake-id"; + var title = "Fake Title"; + var version = "1.0.0-alpha1"; + var description = "Fake Description"; + var contactName = "Fake Contact Name"; + var contactUri = new Uri("https://fake-contact-uri.com"); + var contactEmail = "fake@email.com"; + var licenseName = "Apache 2.0"; + var licenseUri = new Uri("https://fake-contact-uri.com"); + var termsOfServiceUri = new Uri("https://fake.com/terms-of-service"); + var defaultContentType = MediaTypeNames.Application.Json; + var tagName = "fake-document-tag"; + var tagDescription = "Fake Document Tag Description"; + var tagDocumentationUri = new Uri("https://fake-uri.com"); + var tagDocumentationDescription = "Fake Document Tag Documentation Description"; + var serverName = "fake-server"; + var serverHost = "fake-uri.com"; + var serverProtocol = AsyncApiProtocol.Http; + var serverDescription = "fake-server-description"; + var serverVariableName = "fake-server-variable"; + var serverVariableDefaultValue = "fake-server-variable-default"; + var serverVariableEnumValues = new string[] { "value1", "value2", "value3" }; + var serverVariableDescription = "Fake Server Variable Description"; + var channelName = "fake-channel"; + var channelDescription = "Fake Channel Description"; + var channelParameterName = "fakeChannelParam"; + var channelParameterLocation = "/MQMD/CorrelId"; + var channelParameterDescription = "Fake Channel Param Description"; + var channelParameterSchema = new JsonSchemaBuilder().FromType(); + var sendMessageName = "fake-receive-message"; + var sendOperationName = "fake-send-operation"; + var sendOperationChannelRef = $"#/channels/{channelName}"; + var sendOperationMessageRef = $"#/components/messages/{sendMessageName}"; + var sendOperationDescription = "Fake Send Operation Description"; + var sendOperationSummary = "Fake Send Operation Summary"; + var receiveMessageName = "fake-receive-message"; + var receiveOperationName = "fake-receive-operation"; + var receiveOperationChannelRef = $"#/channels/{channelName}"; + var receiveOperationMessageRef = $"#/components/messages/{receiveMessageName}"; + var receiveOperationDescription = "Fake Receive Operation Description"; + var receiveOperationSummary = "Fake Receive Operation Summary"; + + //act + var document = this.V3Builder + .WithSpecVersion(specVersion) + .WithId(id) + .WithTitle(title) + .WithVersion(version) + .WithDescription(description) + .WithContact(contactName, contactUri, contactEmail) + .WithLicense(licenseName, licenseUri) + .WithTermsOfService(termsOfServiceUri) + .WithDefaultContentType(defaultContentType) + .WithServer(serverName, server => server + .WithHost(serverHost) + .WithProtocol(serverProtocol, "2") + .WithDescription(serverDescription) + .WithVariable(serverVariableName, variable => variable + .WithDefaultValue(serverVariableDefaultValue) + .WithEnumValues(serverVariableEnumValues) + .WithDescription(serverVariableDescription)) + .WithBinding(new HttpServerBindingDefinition())) + .WithChannel(channelName, channel => channel + .WithDescription(channelDescription) + .WithBinding(new HttpChannelBindingDefinition()) + .WithParameter(channelParameterName, parameter => parameter + .WithLocation(channelParameterLocation) + .WithDescription(channelParameterDescription)) + .WithTag(tag => tag + .WithName(tagName) + .WithDescription(tagDescription) + .WithExternalDocumentation(tagDocumentationUri, tagDocumentationDescription))) + .WithOperation(sendOperationName, publish => publish + .WithAction(v3.V3OperationAction.Send) + .WithChannel(sendOperationChannelRef) + .WithDescription(sendOperationDescription) + .WithSummary(sendOperationSummary) + .WithBinding(new HttpOperationBindingDefinition()) + .WithMessage(sendOperationMessageRef)) + .WithOperation(receiveOperationName, subscribe => subscribe + .WithAction(v3.V3OperationAction.Receive) + .WithChannel(receiveOperationChannelRef) + .WithDescription(receiveOperationDescription) + .WithSummary(receiveOperationSummary) + .WithBinding(new HttpOperationBindingDefinition()) + .WithMessage(receiveOperationMessageRef)) + .WithExternalDocumentation(documentation => documentation + .WithUrl(tagDocumentationUri) + .WithDescription(tagDocumentationDescription)) + .WithTag(tag => tag + .WithName(tagName) + .WithDescription(tagDescription) + .WithExternalDocumentation(tagDocumentationUri, tagDocumentationDescription)) + .Build(); + + //assert + document.AsyncApi.Should().Be(specVersion); + document.Id.Should().Be(id); + document.Info.Title.Should().Be(title); + document.Info.Version.Should().Be(version); + document.Info.Description.Should().Be(description); + document.Info.Contact.Should().NotBeNull(); + document.Info.Contact!.Name.Should().Be(contactName); + document.Info.Contact!.Email.Should().Be(contactEmail); + document.Info.Contact!.Url.Should().Be(contactUri); + document.Info.License.Should().NotBeNull(); + document.Info.License!.Name.Should().Be(licenseName); + document.Info.License.Url.Should().Be(licenseUri); + document.Info.TermsOfService.Should().Be(termsOfServiceUri); + document.DefaultContentType.Should().Be(defaultContentType); + document.Info.ExternalDocs.Should().NotBeNull(); + document.Info.ExternalDocs!.Description.Should().Be(tagDocumentationDescription); + document.Info.ExternalDocs.Url.Should().Be(tagDocumentationUri); + + var server = document.Servers!.SingleOrDefault(); + server.Should().NotBeNull(); + server.Key.Should().Be(serverName); + server.Value.Host.Should().Be(serverHost); + server.Value.Protocol.Should().Be(serverProtocol); + server.Value.Description.Should().Be(serverDescription); + server.Value.Bindings.Should().NotBeNull(); + server.Value.Bindings!.Http.Should().NotBeNull(); + + var variable = server.Value.Variables!.SingleOrDefault(); + variable.Should().NotBeNull(); + variable.Key.Should().Be(serverVariableName); + variable.Value.Default.Should().Be(serverVariableDefaultValue); + variable.Value.Enum.Should().BeEquivalentTo(serverVariableEnumValues); + variable.Value.Description.Should().Be(serverVariableDescription); + + var channel = document.Channels!.SingleOrDefault(); + channel.Should().NotBeNull(); + channel.Key.Should().Be(channelName); + channel.Value.Bindings.Should().NotBeNull(); + channel.Value.Bindings!.Http.Should().NotBeNull(); + + var sendOperation = document.Operations?.FirstOrDefault(o => o.Key == sendOperationName).Value; + sendOperation.Should().NotBeNull(); + sendOperation!.Description.Should().Be(sendOperationDescription); + sendOperation.Summary.Should().Be(sendOperationSummary); + sendOperation.Channel.Should().NotBeNull(); + sendOperation.Channel.Reference.Should().Be(sendOperationChannelRef); + sendOperation.Messages.Should().NotBeNull(); + sendOperation.Messages.Should().Contain(m => m.Reference == sendOperationMessageRef); + + var receiveOperation = document.Operations?.FirstOrDefault(o => o.Key == receiveOperationName).Value; + receiveOperation.Should().NotBeNull(); + receiveOperation!.Description.Should().Be(receiveOperationDescription); + receiveOperation.Summary.Should().Be(receiveOperationSummary); + receiveOperation.Channel.Should().NotBeNull(); + receiveOperation.Channel.Reference.Should().Be(receiveOperationChannelRef); + receiveOperation.Messages.Should().NotBeNull(); + receiveOperation.Messages.Should().Contain(m => m.Reference == receiveOperationMessageRef); + + var parameter = channel.Value.Parameters!.SingleOrDefault(); + parameter.Should().NotBeNull(); + parameter.Key.Should().Be(channelParameterName); + parameter.Value.Location.Should().Be(channelParameterLocation); + parameter.Value.Description.Should().Be(channelParameterDescription); + + var tag = document.Info.Tags!.SingleOrDefault(); + tag.Should().NotBeNull(); + tag!.Name.Should().Be(tagName); + tag.Description.Should().Be(tagDescription); + tag.ExternalDocs.Should().NotBeNull(); + tag.ExternalDocs!.Description.Should().Be(tagDocumentationDescription); + tag.ExternalDocs.Url.Should().Be(tagDocumentationUri); + } + void IDisposable.Dispose() { this.Services.Dispose(); diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Usings.cs b/tests/Neuroglia.AsyncApi.UnitTests/Usings.cs index 3330fea..20900ef 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Usings.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Usings.cs @@ -16,7 +16,6 @@ global using Json.Schema.Generation; global using Microsoft.Extensions.DependencyInjection; global using Neuroglia.AsyncApi.CloudEvents; -global using Neuroglia.AsyncApi.FluentBuilders; global using Neuroglia.AsyncApi.Generation; global using Neuroglia.AsyncApi.UnitTests.Services; global using Neuroglia.AsyncApi.v2; From a2e2f03a20b24988969dc70e91745458722c1152 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Wed, 18 Dec 2024 17:36:36 +0100 Subject: [PATCH 07/21] feat(Generation): Added generators for Async API V3 documents feat(UI): Added views to render Async API V3 components Signed-off-by: Charles d'Avernas --- .../Messages/LightMeasuredEvent.cs | 8 +- .../Messages/MovementDetectedEvent.cs | 6 +- samples/StreetLightsApi/Program.cs | 20 +- .../Properties/launchSettings.json | 1 + .../Services/MovementSensorService.cs | 8 +- .../Services/StreetLightsService.cs | 17 +- .../Services/TemperatureSensorServiceV1.cs | 8 +- .../Services/TemperatureSensorServiceV2.cs | 8 +- .../StreetLightsApi/StreetLightsApi.csproj | 2 +- .../Extensions/StringExtensions.cs | 38 ++++ .../CorrelationIdDefinitionViewModel.cs | 4 +- .../Models/OAuthFlowDefinitionViewModel.cs | 4 +- .../Models/SchemaViewModel.cs | 4 +- .../Models/SecurityRequirementViewModel.cs | 4 +- .../SecuritySchemeDefinitionViewModel.cs | 4 +- .../V2AsyncApiDocumentViewModel.cs} | 10 +- .../V2BindingDefinitionViewModel.cs} | 8 +- .../V2ChannelDefinitionViewModel.cs} | 10 +- .../V2MessageDefinitionViewModel.cs} | 14 +- .../V2OperationDefinitionViewModel.cs} | 8 +- .../V2ServerDefinitionViewModel.cs} | 8 +- .../Models/v3/V3AsyncApiDocumentViewModel.cs | 35 ++++ .../Models/v3/V3BindingDefinitionViewModel.cs | 36 ++++ .../Models/v3/V3ChannelDefinitionViewModel.cs | 36 ++++ .../v3/V3OperationDefinitionViewModel.cs | 36 ++++ .../Models/v3/V3ServerDefinitionViewModel.cs | 36 ++++ .../Neuroglia.AsyncApi.AspNetCore.UI.csproj | 3 +- .../Pages/AsyncApi.cshtml | 184 ++--------------- .../Pages/AsyncApi.cshtml.cs | 34 ++- .../Pages/Shared/_Layout.cshtml | 48 +++-- .../Pages/Shared/_SecurityRequirement.cshtml | 2 +- .../Pages/Shared/v2/_V2AsyncApi.cshtml | 195 ++++++++++++++++++ .../Pages/Shared/v2/_V2AsyncApi.cshtml.cs | 12 ++ .../{_Binding.cshtml => v2/_V2Binding.cshtml} | 5 +- .../{_Message.cshtml => v2/_V2Message.cshtml} | 12 +- .../_V2Operation.cshtml} | 19 +- .../_V2SecurityScheme.cshtml} | 0 .../{_Server.cshtml => v2/_V2Server.cshtml} | 10 +- .../Pages/Shared/v3/_V3AsyncApi.cshtml | 104 ++++++++++ .../Pages/Shared/v3/_V3AsyncApi.cshtml.cs | 12 ++ .../Pages/Shared/v3/_V3Binding.cshtml | 46 +++++ .../Pages/Shared/v3/_V3Channel.cshtml | 59 ++++++ .../Pages/Shared/v3/_V3Channel.cshtml.cs | 12 ++ .../Pages/Shared/v3/_V3Operation.cshtml | 64 ++++++ .../Pages/Shared/v3/_V3Operation.cshtml.cs | 12 ++ .../Pages/Shared/v3/_V3Server.cshtml | 101 +++++++++ .../Pages/_ViewImports.cshtml | 6 +- .../Usings.cs | 3 +- .../AsyncApiDocumentServingMiddleware.cs | 14 +- .../AsyncApiDocumentServingOptions.cs | 8 +- ...syncApiDocumentServingOptionsExtensions.cs | 19 +- .../Neuroglia.AsyncApi.AspNetCore.csproj | 2 +- .../Neuroglia.AsyncApi.CloudEvents.csproj | 2 +- .../Attributes/AsyncApiAttribute.cs | 46 ++--- .../Attributes/TagAttribute.cs | 54 ----- .../IAsyncApiDocument.cs | 15 ++ .../Neuroglia.AsyncApi.Core.csproj | 2 +- src/Neuroglia.AsyncApi.Core/Usings.cs | 1 - .../v2/Attributes/AsyncApiV2Attribute.cs | 26 +++ .../Attributes/ChannelV2Attribute.cs} | 30 +-- .../Attributes/MessageV2Attribute.cs} | 8 +- .../Attributes/OperationV2Attribute.cs} | 12 +- .../PublishOperationV2Attribute.cs} | 16 +- .../SubscribeOperationV2Attribute.cs} | 18 +- .../v2/Attributes/TagV2Attribute.cs | 36 ++++ .../v2/V2AsyncApiDocument.cs | 4 + .../v3/Attributes/AsyncApiV3Attribute.cs | 26 +++ .../Attributes/ChannelParameterV3Attribute.cs | 56 +++++ .../v3/Attributes/ChannelV3Attribute.cs | 65 ++++++ .../v3/Attributes/MessageV3Attribute.cs | 54 +++++ .../v3/Attributes/OperationV3Attribute.cs | 62 ++++++ .../v3/Attributes/TagV3Attribute.cs | 39 ++++ .../v3/V3AsyncApiDocument.cs | 4 + .../IServiceCollectionExtensions.cs | 3 +- ...ncApi.DependencyInjectionExtensions.csproj | 2 +- .../Neuroglia.AsyncApi.FluentBuilders.csproj | 2 +- .../AsyncApiDocumentGenerationOptions.cs | 12 +- .../AsyncApiDocumentGenerator.cs | 162 +-------------- .../AsyncApiDocumentGenerator.v2.cs | 162 +++++++++++++++ .../AsyncApiDocumentGenerator.v3.cs | 181 ++++++++++++++++ .../AsyncApiDocumentProvider.cs | 31 ++- .../AsyncApiGenerationOptions.cs | 12 +- .../AsyncApiGenerationOptionsBuilder.cs | 29 +-- .../DateTimeOffsetJsonSchemaGenerator.cs | 36 ++++ .../IAsyncApiGenerationOptionsBuilder.cs | 12 +- .../IJsonSchemaExampleGenerator.cs | 0 .../Interfaces/IAsyncApiDocumentGenerator.cs | 10 +- .../Interfaces/IAsyncApiDocumentProvider.cs | 22 +- .../JsonSchemaExampleGenerator.cs | 27 +-- .../Neuroglia.AsyncApi.Generation.csproj | 2 +- src/Neuroglia.AsyncApi.Generation/Usings.cs | 4 +- .../XmlDocumentationJsonSchemaRefiner.cs | 55 +++++ .../Neuroglia.AsyncApi.IO.csproj | 2 +- .../Neuroglia.AsyncApi.Validation.csproj | 2 +- .../JsonSchemaExampleGeneratorTests.cs | 2 + .../Neuroglia.AsyncApi.UnitTests.csproj | 2 +- 96 files changed, 2031 insertions(+), 676 deletions(-) create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Extensions/StringExtensions.cs rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/{AsyncApiDocumentViewModel.cs => v2/V2AsyncApiDocumentViewModel.cs} (79%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/{BindingDefinitionViewModel.cs => v2/V2BindingDefinitionViewModel.cs} (77%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/{ChannelDefinitionViewModel.cs => v2/V2ChannelDefinitionViewModel.cs} (76%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/{MessageDefinitionViewModel.cs => v2/V2MessageDefinitionViewModel.cs} (76%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/{OperationDefinitionViewModel.cs => v2/V2OperationDefinitionViewModel.cs} (76%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/{ServerDefinitionViewModel.cs => v2/V2ServerDefinitionViewModel.cs} (78%) create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionViewModel.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ChannelDefinitionViewModel.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationDefinitionViewModel.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerDefinitionViewModel.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml.cs rename src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/{_Binding.cshtml => v2/_V2Binding.cshtml} (92%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/{_Message.cshtml => v2/_V2Message.cshtml} (91%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/{_Operation.cshtml => v2/_V2Operation.cshtml} (83%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/{_SecurityScheme.cshtml => v2/_V2SecurityScheme.cshtml} (100%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/{_Server.cshtml => v2/_V2Server.cshtml} (88%) create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Binding.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Server.cshtml delete mode 100644 src/Neuroglia.AsyncApi.Core/Attributes/TagAttribute.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v2/Attributes/AsyncApiV2Attribute.cs rename src/Neuroglia.AsyncApi.Core/{Attributes/ChannelAttribute.cs => v2/Attributes/ChannelV2Attribute.cs} (53%) rename src/Neuroglia.AsyncApi.Core/{Attributes/MessageAttribute.cs => v2/Attributes/MessageV2Attribute.cs} (94%) rename src/Neuroglia.AsyncApi.Core/{Attributes/OperationAttribute.cs => v2/Attributes/OperationV2Attribute.cs} (84%) rename src/Neuroglia.AsyncApi.Core/{Attributes/PublishOperationAttribute.cs => v2/Attributes/PublishOperationV2Attribute.cs} (69%) rename src/Neuroglia.AsyncApi.Core/{Attributes/SubscribeOperationAttribute.cs => v2/Attributes/SubscribeOperationV2Attribute.cs} (68%) create mode 100644 src/Neuroglia.AsyncApi.Core/v2/Attributes/TagV2Attribute.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/Attributes/AsyncApiV3Attribute.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelParameterV3Attribute.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelV3Attribute.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/Attributes/MessageV3Attribute.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/Attributes/OperationV3Attribute.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/Attributes/TagV3Attribute.cs create mode 100644 src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v2.cs create mode 100644 src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v3.cs create mode 100644 src/Neuroglia.AsyncApi.Generation/DateTimeOffsetJsonSchemaGenerator.cs rename src/Neuroglia.AsyncApi.Generation/{Interfaces => }/IAsyncApiGenerationOptionsBuilder.cs (76%) rename src/Neuroglia.AsyncApi.Generation/{Interfaces => }/IJsonSchemaExampleGenerator.cs (100%) create mode 100644 src/Neuroglia.AsyncApi.Generation/XmlDocumentationJsonSchemaRefiner.cs diff --git a/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs b/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs index 83ba78b..72dab12 100644 --- a/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs +++ b/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs @@ -11,10 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.v2; + namespace StreetLightsApi.Server.Messages; -[Tag("light", "A tag for light-related messages"), Tag("measurement", "A tag for measurement-related messages")] -[Message(Name = "LightMeasured", Description = "A message used to measure light")] +[TagV2("light", "A tag for light-related messages"), TagV2("measurement", "A tag for measurement-related messages")] +[MessageV2(Name = "LightMeasured", Description = "A message used to measure light")] public class LightMeasuredEvent { @@ -33,6 +35,6 @@ public class LightMeasuredEvent [Description("The event's metadata")] public IDictionary? Metadata { get; set; } - public List Todos { get; set; } + public List Todo { get; set; } = []; } diff --git a/samples/StreetLightsApi/Messages/MovementDetectedEvent.cs b/samples/StreetLightsApi/Messages/MovementDetectedEvent.cs index 2eed046..6c82149 100644 --- a/samples/StreetLightsApi/Messages/MovementDetectedEvent.cs +++ b/samples/StreetLightsApi/Messages/MovementDetectedEvent.cs @@ -11,10 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.v2; + namespace StreetLightsApi.Server.Messages; -[Tag("movement", "A tag for movement-related messages"), Tag("sensor", "A tag for sensor-related messages")] -[Message(Name = "MovementDetected")] +[TagV2("movement", "A tag for movement-related messages"), TagV2("sensor", "A tag for sensor-related messages")] +[MessageV2(Name = "MovementDetected")] public class MovementDetectedEvent { diff --git a/samples/StreetLightsApi/Program.cs b/samples/StreetLightsApi/Program.cs index 8f44274..064d635 100644 --- a/samples/StreetLightsApi/Program.cs +++ b/samples/StreetLightsApi/Program.cs @@ -34,7 +34,7 @@ builder.Services.AddAsyncApiUI(); builder.Services.AddAsyncApiGeneration(builder => builder.WithMarkupType() - .UseDefaultConfiguration(asyncApi => + .UseDefaultV2DocumentConfiguration(asyncApi => { asyncApi .WithTermsOfService(new Uri("https://www.websitepolicies.com/blog/sample-terms-service-template")) @@ -47,6 +47,24 @@ ClientId = "StreetLightsAPI:1.0.0", CleanSession = true })); + }) + .UseDefaultV3DocumentConfiguration(asyncApi => + { + asyncApi + .WithTermsOfService(new Uri("https://www.websitepolicies.com/blog/sample-terms-service-template")) + .WithServer("mosquitto", server => server + .WithHost("mqtt://test.mosquitto.org") + .WithPathName("/{environment}") + .WithProtocol(AsyncApiProtocol.Mqtt) + .WithDescription("The **Mosquitto test MQTT server**. Use the `env` variable to point to either `production` or `staging`.") + .WithVariable("environment", variable => variable + .WithDescription("Environment to connect to.") + .WithEnumValues("production", "staging")) + .WithBinding(new MqttServerBindingDefinition() + { + ClientId = "StreetLightsAPI:1.0.0", + CleanSession = true + })); })); builder.Services.AddAsyncApiDocument(document => document .WithTitle("Cloud Event API") diff --git a/samples/StreetLightsApi/Properties/launchSettings.json b/samples/StreetLightsApi/Properties/launchSettings.json index 76865e1..bc0a0f6 100644 --- a/samples/StreetLightsApi/Properties/launchSettings.json +++ b/samples/StreetLightsApi/Properties/launchSettings.json @@ -14,6 +14,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "applicationUrl": "http://localhost:5055", + "launchUrl": "asyncapi", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/samples/StreetLightsApi/Services/MovementSensorService.cs b/samples/StreetLightsApi/Services/MovementSensorService.cs index c1f4b31..c9c73b3 100644 --- a/samples/StreetLightsApi/Services/MovementSensorService.cs +++ b/samples/StreetLightsApi/Services/MovementSensorService.cs @@ -11,9 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.v2; + namespace StreetLightsApi.Server.Services; -[AsyncApi("Movement Sensor API", "1.0.0", Description = "The Movement Sensor API allows you to get remotely notified about movements captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] +[AsyncApiV2("Movement Sensor API", "1.0.0", Description = "The Movement Sensor API allows you to get remotely notified about movements captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] public class MovementSensorService(ILogger logger, IJsonSerializer serializer) : BackgroundService { @@ -39,8 +41,8 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await this.MqttClient.SubscribeAsync("OnMovementDetected", cancellationToken: stoppingToken).ConfigureAwait(false); } - [Tag("movement", "A tag for movement-related operations"), Tag("sensor", "A tag for sensor-related operations")] - [Channel("movement/detected"), SubscribeOperation(OperationId = "OnMovementDetected", Summary = "Inform about movement captured by sensors")] + [TagV2("movement", "A tag for movement-related operations"), TagV2("sensor", "A tag for sensor-related operations")] + [ChannelV2("movement/detected"), SubscribeOperationV2(OperationId = "OnMovementDetected", Summary = "Inform about movement captured by sensors")] protected Task OnMovementDetected(MovementDetectedEvent e) { this.Logger.LogInformation("Movement detected by sensor with id '{sensorId}' at {sentAt}", e.SensorId, e.SentAt); diff --git a/samples/StreetLightsApi/Services/StreetLightsService.cs b/samples/StreetLightsApi/Services/StreetLightsService.cs index e505d77..8d5171a 100644 --- a/samples/StreetLightsApi/Services/StreetLightsService.cs +++ b/samples/StreetLightsApi/Services/StreetLightsService.cs @@ -11,12 +11,19 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.v2; +using Neuroglia.AsyncApi.v3; + namespace StreetLightsApi.Server.Services; -[AsyncApi("Streetlights API", "1.0.0", Description = "The Smartylighting Streetlights API allows you to remotely manage the city lights.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] +[AsyncApiV2("Streetlights API", "1.0.0", Description = "The Smartylighting Streetlights API allows you to remotely manage the city lights.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] +[AsyncApiV3("Streetlights API", "1.0.0", Description = "The **Smartylighting Streetlights API** allows you to remotely manage the city lights.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] +[ChannelV3("lightingMeasured", Address = "streets.{streetName}", Description = "This channel is used to exchange messages about lightning measurements.", Servers = ["#/servers/mosquitto"])] +[ChannelParameterV3("lightingMeasured", "streetName", Description = "The name of the **street** the lights to get measurements for are located in")] public class StreetLightsService(ILogger logger, IJsonSerializer serializer) : BackgroundService { + protected ILogger Logger { get; } = logger; protected IJsonSerializer Serializer { get; } = serializer; @@ -39,8 +46,8 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await this.PublishLightMeasured(new() { Id = Guid.NewGuid(), Lumens = 5, SentAt = DateTime.UtcNow }, stoppingToken).ConfigureAwait(false); } - [Tag("light", "A tag for light-related operations"), Tag("measurement", "A tag for measurement-related operations")] - [Channel("light/measured"), PublishOperation(OperationId = "NotifyLightMeasured", Summary = "Notifies remote consumers about environmental lighting conditions for a particular streetlight")] + [ChannelV2("light/measured"), PublishOperationV2(OperationId = "NotifyLightMeasured", Summary = "Notifies remote consumers about environmental lighting conditions for a particular streetlight."), TagV2("light", "A tag for light-related operations"), TagV2("measurement", "A tag for measurement-related operations")] + [OperationV3("sendLightMeasurement", V3OperationAction.Send, "#/channels/lightingMeasured", Description = "Notifies remote **consumers** about environmental lighting conditions for a particular **streetlight**."), TagV3(Reference = "#/components/tags/measurement")] public async Task PublishLightMeasured(LightMeasuredEvent e, CancellationToken cancellationToken = default) { var message = new MqttApplicationMessage() @@ -52,8 +59,8 @@ public async Task PublishLightMeasured(LightMeasuredEvent e, CancellationToken c await this.MqttClient.PublishAsync(message, cancellationToken); } - [Tag("light", "A tag for light-related operations"), Tag("measurement", "A tag for measurement-related operations")] - [Channel("light/measured"), SubscribeOperation(OperationId = "OnLightMeasured", Summary = "Inform about environmental lighting conditions for a particular streetlight")] + [ChannelV2("light/measured"), SubscribeOperationV2(OperationId = "OnLightMeasured", Summary = "Inform about environmental lighting conditions for a particular streetlight"), TagV2("light", "A tag for light-related operations"), TagV2("measurement", "A tag for measurement-related operations")] + [OperationV3("receiveLightMeasurement", V3OperationAction.Receive, "#/channels/lightingMeasured"), TagV3(Reference = "#/components/tags/measurement")] protected Task OnLightMeasured(LightMeasuredEvent e) { this.Logger.LogInformation("Event received:\r\n{json}", this.Serializer.SerializeToText(e)); diff --git a/samples/StreetLightsApi/Services/TemperatureSensorServiceV1.cs b/samples/StreetLightsApi/Services/TemperatureSensorServiceV1.cs index 44d1ef0..a949c7f 100644 --- a/samples/StreetLightsApi/Services/TemperatureSensorServiceV1.cs +++ b/samples/StreetLightsApi/Services/TemperatureSensorServiceV1.cs @@ -11,9 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.v2; + namespace StreetLightsApi.Server.Services; -[AsyncApi("Temperature Sensor API", "1.0.0", Description = "The Temperature Sensor API allows you to get remotely notified about temperature changes captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] +[AsyncApiV2("Temperature Sensor API", "1.0.0", Description = "The Temperature Sensor API allows you to get remotely notified about temperature changes captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] public class TemperatureSensorServiceV1(ILogger logger, IJsonSerializer serializer) : BackgroundService { @@ -39,8 +41,8 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await this.MqttClient.SubscribeAsync("OnTemperatureChanged", cancellationToken: stoppingToken).ConfigureAwait(false); } - [Tag("temperature", "A tag for temeprature-related operations"), Tag("sensor", "A tag for sensor-related operations")] - [Channel("temperature/changed"), SubscribeOperation(OperationId = "OnTemperatureChanged", Summary = "Inform about temperature changes captured by sensors")] + [TagV2("temperature", "A tag for temperature-related operations"), TagV2("sensor", "A tag for sensor-related operations")] + [ChannelV2("temperature/changed"), SubscribeOperationV2(OperationId = "OnTemperatureChanged", Summary = "Inform about temperature changes captured by sensors")] protected Task OnTemperatureChanged([Range(-100, 100)]decimal degrees) { this.Logger.LogInformation("Temperature is {degrees}° Celsius", degrees); diff --git a/samples/StreetLightsApi/Services/TemperatureSensorServiceV2.cs b/samples/StreetLightsApi/Services/TemperatureSensorServiceV2.cs index 90d0544..2a743b2 100644 --- a/samples/StreetLightsApi/Services/TemperatureSensorServiceV2.cs +++ b/samples/StreetLightsApi/Services/TemperatureSensorServiceV2.cs @@ -11,9 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.v2; + namespace StreetLightsApi.Server.Services; -[AsyncApi("Temperature Sensor API", "2.0.0", Description = "The Temperature Sensor API allows you to get remotely notified about temperature changes captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] +[AsyncApiV2("Temperature Sensor API", "2.0.0", Description = "The Temperature Sensor API allows you to get remotely notified about temperature changes captured by sensors.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] public class TemperatureSensorServiceV2(ILogger logger, IJsonSerializer serializer) : BackgroundService { @@ -39,8 +41,8 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await this.MqttClient.SubscribeAsync("OnTemperatureChanged", cancellationToken: stoppingToken).ConfigureAwait(false); } - [Tag("temperature", "A tag for temperature-related operations"), Tag("sensor", "A tag for sensor-related operations")] - [Channel("temperature/changed"), SubscribeOperation(OperationId = "OnTemperatureChanged", Summary = "Inform about temperature changes captured by sensors")] + [TagV2("temperature", "A tag for temperature-related operations"), TagV2("sensor", "A tag for sensor-related operations")] + [ChannelV2("temperature/changed"), SubscribeOperationV2(OperationId = "OnTemperatureChanged", Summary = "Inform about temperature changes captured by sensors")] protected async Task OnTemperatureChanged([Range(-100,100)]decimal degrees, DateTime timestamp) { this.Logger.LogInformation("{timestamp}: {degrees}°", timestamp, degrees); diff --git a/samples/StreetLightsApi/StreetLightsApi.csproj b/samples/StreetLightsApi/StreetLightsApi.csproj index 8378108..51aa229 100644 --- a/samples/StreetLightsApi/StreetLightsApi.csproj +++ b/samples/StreetLightsApi/StreetLightsApi.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Extensions/StringExtensions.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Extensions/StringExtensions.cs new file mode 100644 index 0000000..f718411 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Extensions/StringExtensions.cs @@ -0,0 +1,38 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Text.RegularExpressions; + +namespace Neuroglia.AsyncApi; + +/// +/// Defines extensions for strings +/// +public static class StringExtensions +{ + + /// + /// Wraps placeholders with code tags + /// + /// The input string + /// The resulting string + public static string WrapPlaceholdersWithCodeTags(this string input) + { + if (string.IsNullOrEmpty(input)) return input; + var pattern = @"\{[^}]+\}"; + var replacement = "$&"; + var result = Regex.Replace(input, pattern, replacement); + return result; + } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs index da55320..51df652 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs @@ -11,13 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; + namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; /// /// Holds the data used to render an view /// public record CorrelationIdDefinitionViewModel - : AsyncApiDocumentViewModel + : V2AsyncApiDocumentViewModel { /// diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs index ef97b89..db6bb44 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs @@ -11,13 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; + namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; /// /// Holds the data used to render a view /// public record OAuthFlowDefinitionViewModel - : AsyncApiDocumentViewModel + : V2AsyncApiDocumentViewModel { /// diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs index 2fb9b8e..8bf0bbc 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs @@ -11,13 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; + namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; /// /// Holds the data used to render a view /// public record SchemaViewModel - : AsyncApiDocumentViewModel + : V2AsyncApiDocumentViewModel { /// diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs index c2968ec..600cf6e 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs @@ -11,13 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; + namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; /// /// Holds the data used to render a security requirement view /// public record SecurityRequirementViewModel - : AsyncApiDocumentViewModel + : V2AsyncApiDocumentViewModel { /// diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs index b481904..7e2502e 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs @@ -11,13 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; + namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; /// /// Holds the data used to render a view /// public record SecuritySchemeDefinitionViewModel - : AsyncApiDocumentViewModel + : V2AsyncApiDocumentViewModel { /// diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/AsyncApiDocumentViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2AsyncApiDocumentViewModel.cs similarity index 79% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/AsyncApiDocumentViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2AsyncApiDocumentViewModel.cs index c13e481..8fcc555 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/AsyncApiDocumentViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2AsyncApiDocumentViewModel.cs @@ -11,23 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render an view /// -public record AsyncApiDocumentViewModel +public record V2AsyncApiDocumentViewModel { /// - /// Initializes a new + /// Initializes a new /// /// The to render the view for - public AsyncApiDocumentViewModel(V2AsyncApiDocument document) => this.Document = document; + public V2AsyncApiDocumentViewModel(V2AsyncApiDocument document) => Document = document; /// /// Gets the to render the view for /// public V2AsyncApiDocument Document { get; } -} \ No newline at end of file +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/BindingDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2BindingDefinitionViewModel.cs similarity index 77% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/BindingDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2BindingDefinitionViewModel.cs index 1fa7ba5..dd26be1 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/BindingDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2BindingDefinitionViewModel.cs @@ -13,17 +13,17 @@ using Neuroglia.AsyncApi.Bindings; -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render an view /// -public record BindingDefinitionViewModel - : AsyncApiDocumentViewModel +public record V2BindingDefinitionViewModel + : V2AsyncApiDocumentViewModel { /// - public BindingDefinitionViewModel(V2AsyncApiDocument document, IBindingDefinition binding, string parentRef) : base(document) { this.Binding = binding; this.ParentRef = parentRef; } + public V2BindingDefinitionViewModel(V2AsyncApiDocument document, IBindingDefinition binding, string parentRef) : base(document) { Binding = binding; ParentRef = parentRef; } /// /// Gets the to render diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ChannelDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2ChannelDefinitionViewModel.cs similarity index 76% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ChannelDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2ChannelDefinitionViewModel.cs index f406c9d..59f17b7 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ChannelDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2ChannelDefinitionViewModel.cs @@ -11,18 +11,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render an view /// -public record ChannelDefinitionViewModel - : AsyncApiDocumentViewModel +public record V2ChannelDefinitionViewModel + : V2AsyncApiDocumentViewModel { /// - public ChannelDefinitionViewModel(V2AsyncApiDocument document, V2ChannelDefinition channel) : base(document) => this.Channel = channel; - + public V2ChannelDefinitionViewModel(V2AsyncApiDocument document, V2ChannelDefinition channel) : base(document) => Channel = channel; + /// /// Gets the to render /// diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/MessageDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2MessageDefinitionViewModel.cs similarity index 76% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/MessageDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2MessageDefinitionViewModel.cs index b601cd1..7ccf595 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/MessageDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2MessageDefinitionViewModel.cs @@ -11,22 +11,22 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render a view /// -public record MessageDefinitionViewModel - : AsyncApiDocumentViewModel +public record V2MessageDefinitionViewModel + : V2AsyncApiDocumentViewModel { /// - public MessageDefinitionViewModel(V2AsyncApiDocument document, int index, string operationRef, V2MessageDefinition definition) + public V2MessageDefinitionViewModel(V2AsyncApiDocument document, int index, string operationRef, V2MessageDefinition definition) : base(document) { - this.Index = index; - this.OperationRef = operationRef; - this.Definition = definition; + Index = index; + OperationRef = operationRef; + Definition = definition; } /// diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OperationDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2OperationDefinitionViewModel.cs similarity index 76% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OperationDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2OperationDefinitionViewModel.cs index bd6e279..8be0b93 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OperationDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2OperationDefinitionViewModel.cs @@ -11,17 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render a view /// -public record OperationDefinitionViewModel - : AsyncApiDocumentViewModel +public record V2OperationDefinitionViewModel + : V2AsyncApiDocumentViewModel { /// - public OperationDefinitionViewModel(V2AsyncApiDocument document, string channelKey, V2OperationType operationType, V2OperationDefinition operation) : base(document) { this.ChannelKey = channelKey; this.OperationType = operationType; this.Operation = operation; } + public V2OperationDefinitionViewModel(V2AsyncApiDocument document, string channelKey, V2OperationType operationType, V2OperationDefinition operation) : base(document) { ChannelKey = channelKey; OperationType = operationType; Operation = operation; } /// /// Gets the key of the the to render belongs to diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ServerDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2ServerDefinitionViewModel.cs similarity index 78% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ServerDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2ServerDefinitionViewModel.cs index dcd76cc..e553db2 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/ServerDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2ServerDefinitionViewModel.cs @@ -11,17 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render a view /// -public record ServerDefinitionViewModel - : AsyncApiDocumentViewModel +public record V2ServerDefinitionViewModel + : V2AsyncApiDocumentViewModel { /// - public ServerDefinitionViewModel(V2AsyncApiDocument document, string key, V2ServerDefinition server) : base(document) { this.Key = key; this.Server = server; } + public V2ServerDefinitionViewModel(V2AsyncApiDocument document, string key, V2ServerDefinition server) : base(document) { Key = key; Server = server; } /// /// Gets the key of the to render diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs new file mode 100644 index 0000000..a2ec0ae --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs @@ -0,0 +1,35 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.v3; + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +public record V3AsyncApiDocumentViewModel +{ + + /// + /// Initializes a new + /// + /// The to render the view for + public V3AsyncApiDocumentViewModel(V3AsyncApiDocument document) => Document = document; + + /// + /// Gets the to render the view for + /// + public V3AsyncApiDocument Document { get; } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionViewModel.cs new file mode 100644 index 0000000..3d7850b --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionViewModel.cs @@ -0,0 +1,36 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +public record V3BindingDefinitionViewModel + : V3AsyncApiDocumentViewModel +{ + + /// + public V3BindingDefinitionViewModel(V3AsyncApiDocument document, IBindingDefinition binding, string parentRef) : base(document) { Binding = binding; ParentRef = parentRef; } + + /// + /// Gets the to render + /// + public IBindingDefinition Binding { get; } + + /// + /// Gets the reference of the 's parent component + /// + public string ParentRef { get; } + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ChannelDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ChannelDefinitionViewModel.cs new file mode 100644 index 0000000..c11f86f --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ChannelDefinitionViewModel.cs @@ -0,0 +1,36 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The document the to render belongs to +/// The name of the to render +/// The to render +public record V3ChannelDefinitionViewModel(V3AsyncApiDocument document, string channelName, V3ChannelDefinition channel) + : V3AsyncApiDocumentViewModel(document) +{ + + /// + /// Gets the name of the to render + /// + public string ChannelName { get; } = channelName; + + /// + /// Gets the to render + /// + public V3ChannelDefinition Channel { get; } = channel; + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationDefinitionViewModel.cs new file mode 100644 index 0000000..b5512a9 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationDefinitionViewModel.cs @@ -0,0 +1,36 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render a view +/// +/// The that defines the to render +/// The name of the to render +/// The to render +public record V3OperationDefinitionViewModel(V3AsyncApiDocument document, string operationName, V3OperationDefinition operation) + : V3AsyncApiDocumentViewModel(document) +{ + + /// + /// Gets the name of the to render + /// + public string OperationName { get; } = operationName; + + /// + /// Gets the to render + /// + public V3OperationDefinition Operation { get; } = operation; + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerDefinitionViewModel.cs new file mode 100644 index 0000000..120d6b9 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerDefinitionViewModel.cs @@ -0,0 +1,36 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render a view +/// +public record V3ServerDefinitionViewModel + : V3AsyncApiDocumentViewModel +{ + + /// + public V3ServerDefinitionViewModel(V3AsyncApiDocument document, string key, V3ServerDefinition server) : base(document) { Key = key; Server = server; } + + /// + /// Gets the key of the to render + /// + public string Key { get; } + + /// + /// Gets the to render + /// + public V3ServerDefinition Server { get; } + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Neuroglia.AsyncApi.AspNetCore.UI.csproj b/src/Neuroglia.AsyncApi.AspNetCore.UI/Neuroglia.AsyncApi.AspNetCore.UI.csproj index 4f5694b..86b9df3 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Neuroglia.AsyncApi.AspNetCore.UI.csproj +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Neuroglia.AsyncApi.AspNetCore.UI.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable Library @@ -35,6 +35,7 @@ + diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml index 3a702a9..3f44c83 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml @@ -3,9 +3,10 @@ @model Neuroglia.AsyncApi.AspNetCore.UI.Pages.AsyncApiDocumentModel @inject Microsoft.Extensions.Options.IOptions ServingOptions @{ - var document = this.Model.Document!; - this.ViewBag.Title = document?.Info.Title; + var document = this.Model.Document; + this.ViewBag.Title = document?.Title; } +
@if (document == null) { @@ -20,176 +21,17 @@ } else { -
-
- @document.Info.Title - @document.Info.Version -
- - -
- -
- @if (document.Info.License != null || document.Info.TermsOfService != null) - { -
- @if (document.Info.License != null && document.Info.License.Url != null) - { - @document.Info.License.Name - } - @if (document.Info.TermsOfService != null) - { - Terms of Service - } -
- } - @if (!string.IsNullOrWhiteSpace(document.Info.Description)) - { -

@document.Info.Description

- } -
-
- -
- @if (document.Servers != null) - { - foreach (var server in document.Servers) - { - - } - } -
-
-
- -
- @foreach (var channel in document.Channels) - { - if (channel.Value.Publish != null) - { - - } - if (channel.Value.Subscribe != null) - { - - } - } -
-
- @if (document.Components != null) + switch (document) { -
- -
- @if (document.Components.Schemas != null) - { -
- -
- @{ - var index = 0; - foreach (var schema in document.Components.Schemas) - { - var reference = $"components_schemas_{index}"; - - index++; - } - } -
-
- } - @if(document.Components.Messages != null) - { -
- -
- @{ - var index = 0; - foreach (var message in document.Components.Messages) - { - var reference = $"components_messages_{index}"; - - index++; - } - } -
-
- } - @if(document.Components.SecuritySchemes != null) - { -
- -
- @{ - var index = 0; - foreach (var scheme in document.Components.SecuritySchemes) - { - var reference = $"components_security_schemes_{index}"; - - index++; - } - } -
-
- } -
-
+ case V2AsyncApiDocument: + + break; + case V3AsyncApiDocument: + + break; + default: +

Unsupported Async API Specification version '@document.AsyncApi'

+ break; } }
diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml.cs index 3cffa6b..2c91026 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/AsyncApi.cshtml.cs @@ -17,12 +17,9 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Pages; /// -/// Represents the model of the page used to render an +/// Represents the model of the page used to render an /// -/// -/// Initializes a new -/// -/// The service used to access generated s +/// The service used to access generated s public class AsyncApiDocumentModel(IAsyncApiDocumentProvider documents) : PageModel { @@ -30,26 +27,27 @@ public class AsyncApiDocumentModel(IAsyncApiDocumentProvider documents) IAsyncApiDocumentProvider Documents { get; } = documents; /// - /// Gets the requested 's title + /// Gets the requested 's title /// public string? RequestedTitle { get; private set; } /// - /// Gets the requested 's version + /// Gets the requested 's version /// public string? RequestedVersion { get; private set; } /// - /// Gets the current + /// Gets the current /// - public V2AsyncApiDocument? Document { get; private set; } + public IAsyncApiDocument? Document { get; private set; } /// - /// Renders the with the specified title and version + /// Renders the with the specified title and version /// - /// The title of the to render - /// The version of the to render - public void OnGet(string title, string version) + /// The Async API version in which the to render has been written in + /// The title of the to render + /// The version of the to render + public void OnGet(string specVersion, string title, string version) { this.RequestedTitle = title; this.RequestedVersion = version; @@ -61,15 +59,13 @@ public void OnGet(string title, string version) { if (string.IsNullOrWhiteSpace(version)) this.Document = this.Documents - .Where(d => - d.Info.Title.Equals(title, StringComparison.OrdinalIgnoreCase)) - .OrderByDescending(d => d.Info.Version) + .Where(d => d.AsyncApi == specVersion && d.Title.Equals(title, StringComparison.OrdinalIgnoreCase)) + .OrderByDescending(d => d.Version) .FirstOrDefault(); else this.Document = this.Documents - .Where(d => - d.Info.Title.Equals(title, StringComparison.OrdinalIgnoreCase)) - .FirstOrDefault(d => d.Info.Version.Equals(version, StringComparison.OrdinalIgnoreCase)); + .Where(d => d.AsyncApi == specVersion && d.Title.Equals(title, StringComparison.OrdinalIgnoreCase)) + .FirstOrDefault(d => d.Version.Equals(version, StringComparison.OrdinalIgnoreCase)); } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml index 9af9193..cd30906 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml @@ -1,6 +1,10 @@ -@inject Neuroglia.AsyncApi.Generation.IAsyncApiDocumentProvider DocumentProvider -@inject Microsoft.Extensions.Options.IOptions Options; +@inject IAsyncApiDocumentProvider DocumentProvider +@inject Microsoft.Extensions.Options.IOptions Options; @{ + if (!this.Context.Request.Query.TryGetValue("specVersion", out var documentSpecVersion)) + { + documentSpecVersion = string.Empty; + } if(!this.Context.Request.Query.TryGetValue("title", out var documentTitle)) { documentTitle = string.Empty; @@ -76,6 +80,27 @@ margin: 5px; } + a[data-bs-toggle="collapse"] i.caret:before { + display: inline-block; + font-family: bootstrap-icons !important; + font-style: normal; + font-weight: normal !important; + font-variant: normal; + text-transform: none; + line-height: 1; + vertical-align: -.125em; + content: "\f22c"; + } + + a[data-bs-toggle="collapse"].collapsed i.caret:before { + content: "\f22c"; + transform: rotate(270deg); + } + + .w-60-px{ + width: 60px; + } + @@ -90,17 +115,10 @@
@@ -125,9 +143,11 @@ $('select.js-asyncapi-document').on('change', function () { var $this = $(this); const components = $(this).val().split("__"); - const title = components[0]; - const version = components[1]; + const specVersion = components[0]; + const title = components[1]; + const version = components[2]; const newUrl = new URL(window.location.href); + newUrl.searchParams.set("specVersion", specVersion); newUrl.searchParams.set("title", title); newUrl.searchParams.set("version", version); window.location = newUrl.href; diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_SecurityRequirement.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_SecurityRequirement.cshtml index fe1725f..0198602 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_SecurityRequirement.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_SecurityRequirement.cshtml @@ -22,7 +22,7 @@ } else { - + } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml new file mode 100644 index 0000000..f7f8149 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml @@ -0,0 +1,195 @@ +@model Neuroglia.AsyncApi.AspNetCore.UI.Pages.AsyncApiDocumentModel +@inject Microsoft.Extensions.Options.IOptions ServingOptions +@{ + var document = (this.Model.Document as V2AsyncApiDocument)!; +} +
+
+
+ @document.Info.Title + @document.Info.Version +
+ + +
+ +
+ @if (document.Info.License != null || document.Info.TermsOfService != null) + { +
+ @if (document.Info.License != null && document.Info.License.Url != null) + { + @document.Info.License.Name + } + @if (document.Info.TermsOfService != null) + { + Terms of Service + } +
+ } + @if (!string.IsNullOrWhiteSpace(document.Info.Description)) + { +

@document.Info.Description

+ } +
+
+ +
+ @if (document.Servers != null) + { + foreach (var server in document.Servers) + { + + } + } +
+
+
+ +
+ @foreach (var channel in document.Channels) + { + if (channel.Value.Publish != null) + { + + } + if (channel.Value.Subscribe != null) + { + + } + } +
+
+ @if (document.Components != null) + { +
+ +
+ @if (document.Components.Schemas != null) + { +
+ +
+ @{ + var index = 0; + foreach (var schema in document.Components.Schemas) + { + var reference = $"components_schemas_{index}"; + + index++; + } + } +
+
+ } + @if (document.Components.Messages != null) + { +
+ +
+ @{ + var index = 0; + foreach (var message in document.Components.Messages) + { + var reference = $"components_messages_{index}"; + + index++; + } + } +
+
+ } + @if (document.Components.SecuritySchemes != null) + { +
+ +
+ @{ + var index = 0; + foreach (var scheme in document.Components.SecuritySchemes) + { + var reference = $"components_security_schemes_{index}"; + + index++; + } + } +
+
+ } +
+
+ } +
\ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml.cs new file mode 100644 index 0000000..b9169c8 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Pages.Shared +{ + public class _V2DocumentModel : PageModel + { + public void OnGet() + { + } + } +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Binding.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Binding.cshtml similarity index 92% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Binding.cshtml rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Binding.cshtml index 5f49356..10fcee6 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Binding.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Binding.cshtml @@ -1,12 +1,13 @@ -@model BindingDefinitionViewModel +@model V2BindingDefinitionViewModel @{ var binding = this.Model.Binding; var bindingName = binding.GetType().Name.Replace("ServerBindingDefinition", "").Replace("ChannelBindingDefinition", "").Replace("OperationBindingDefinition", "").Replace("MessageBindingDefinition", "").ToUpperInvariant(); }
- diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Message.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Message.cshtml similarity index 91% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Message.cshtml rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Message.cshtml index d7233b8..2365ff2 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Message.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Message.cshtml @@ -1,7 +1,7 @@ @inject IJsonSerializer Serializer @inject IJsonSchemaResolver JsonSchemaResolver @inject IJsonSchemaExampleGenerator ExampleGenerator -@model MessageDefinitionViewModel +@model V2MessageDefinitionViewModel @{ var operationRef = this.Model.OperationRef; var messageRef = $"{operationRef}_message{this.Model.Index}"; @@ -10,10 +10,11 @@ if (payloadSchema != null) payloadSchema = await this.JsonSchemaResolver.ResolveSchemaAsync(payloadSchema); }
-
@@ -56,7 +58,7 @@ { @foreach (var binding in message.Bindings.AsEnumerable()) { - + } }
@@ -67,6 +69,7 @@
@@ -87,6 +90,7 @@
diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Operation.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Operation.cshtml similarity index 83% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Operation.cshtml rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Operation.cshtml index fdf14e1..2c367dc 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Operation.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Operation.cshtml @@ -1,5 +1,5 @@ @inject Neuroglia.Serialization.IJsonSerializer Serializer -@model OperationDefinitionViewModel +@model V2OperationDefinitionViewModel @{ var operationType = this.Model.OperationType; var operation = this.Model.Operation; @@ -16,10 +16,11 @@
-
@@ -59,7 +61,7 @@ { @foreach (var binding in operation.Bindings.AsEnumerable()) { - + } }
@@ -67,9 +69,10 @@
@if(message == null) @@ -78,14 +81,14 @@ } else if (message.OneOf == null || !message.OneOf.Any()) { - + } else { int index = 1; foreach(var messageOption in message.OneOf) { - + index++; } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_SecurityScheme.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2SecurityScheme.cshtml similarity index 100% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_SecurityScheme.cshtml rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2SecurityScheme.cshtml diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Server.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Server.cshtml similarity index 88% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Server.cshtml rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Server.cshtml index 29d0b1e..0cf3931 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Server.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Server.cshtml @@ -1,12 +1,13 @@ -@model ServerDefinitionViewModel +@model V2ServerDefinitionViewModel @{ var server = this.Model.Server; }
-
@@ -77,7 +81,7 @@ { @foreach (var binding in server.Bindings.AsEnumerable()) { - + } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml new file mode 100644 index 0000000..bc78ba4 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml @@ -0,0 +1,104 @@ +@model Neuroglia.AsyncApi.AspNetCore.UI.Pages.AsyncApiDocumentModel +@inject Microsoft.Extensions.Options.IOptions ServingOptions +@{ + var document = (this.Model.Document as V3AsyncApiDocument)!; +} +
+ +
+
+ @document.Info.Title + @document.Info.Version +
+ + +
+ +
+ @if (document.Info.License != null || document.Info.TermsOfService != null) + { +
+ @if (document.Info.License != null && document.Info.License.Url != null) + { + @document.Info.License.Name + } + @if (document.Info.TermsOfService != null) + { + Terms of Service + } +
+ } + @if (!string.IsNullOrWhiteSpace(document.Info.Description)) + { + @Html.Raw(Markdown.ToHtml(document.Info.Description ?? string.Empty)) + } +
+ +
+ +
+ @if (document.Servers != null) + { + foreach (var server in document.Servers) + { + + } + } +
+
+ +
+ +
+ @if (document.Channels != null) + { + foreach (var channel in document.Channels) + { + + } + } +
+
+ +
+ +
+ @if (document.Servers != null) + { + foreach (var operation in document.Operations) + { + + } + } +
+
+ +
\ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml.cs new file mode 100644 index 0000000..c091573 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Pages.Shared +{ + public class V3AsyncApiModel : PageModel + { + public void OnGet() + { + } + } +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Binding.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Binding.cshtml new file mode 100644 index 0000000..68b7ef0 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Binding.cshtml @@ -0,0 +1,46 @@ +@model V3BindingDefinitionViewModel +@{ + var binding = this.Model.Binding; + var bindingName = binding.GetType().Name.Replace("ServerBindingDefinition", "").Replace("ChannelBindingDefinition", "").Replace("OperationBindingDefinition", "").Replace("MessageBindingDefinition", "").ToUpperInvariant(); +} + +
+ +
+
+
+ @{ + var properties = binding.GetType().GetProperties().Where(p => !p.TryGetCustomAttribute(out _)); + if (properties.Any()) + { + foreach (var property in properties) + { + var value = property.GetValue(binding); + if (value == null) continue; +
+ +
+ @property.Name +
+ +
+ @value +
+ +
+ } + } + else + { +

No specific configuration.

+ } + } +
+
+
+
\ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml new file mode 100644 index 0000000..7d3afae --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml @@ -0,0 +1,59 @@ +@model V3ChannelDefinitionViewModel +@{ + var channel = Model.Channel; +} +
+
+ + + +
+ + @if (!string.IsNullOrWhiteSpace(channel.Description)) + { + @Html.Raw(Markdown.ToHtml(channel.Description)) + } + +
+ +
+ @if (channel.Bindings == null || !channel.Bindings.AsEnumerable().Any()) + { +

No bindings defined.

+ } + else + { + @foreach (var binding in channel.Bindings.AsEnumerable()) + { + + } + } +
+
+
+ +
+
\ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml.cs new file mode 100644 index 0000000..7171cb8 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Pages.Shared.v3 +{ + public class _V3ChannelModel : PageModel + { + public void OnGet() + { + } + } +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml new file mode 100644 index 0000000..164bb96 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml @@ -0,0 +1,64 @@ +@model V3OperationDefinitionViewModel +@{ + var operation = Model.Operation; + var badgeColor = operation.Action == V3OperationAction.Send ? "info" : "info"; + var badgeTooltip = operation.Action == V3OperationAction.Send ? "An operation used to publish a message to the specified channel." : "An operation used to subscribe to messages from the specified channel."; + var badgeText = operation.Action == V3OperationAction.Send ? "send" : "receive"; +} +
+
+ + + +
+ + @if (!string.IsNullOrWhiteSpace(operation.Description)) + { + @Html.Raw(Markdown.ToHtml(operation.Description)) + } + +
+ +
+ @if (operation.Bindings == null || !operation.Bindings.AsEnumerable().Any()) + { +

No bindings defined.

+ } + else + { + @foreach (var binding in operation.Bindings.AsEnumerable()) + { + + } + } +
+
+
+ +
+
\ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml.cs new file mode 100644 index 0000000..3607c82 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Pages.Shared.v3 +{ + public class _V3OperationModel : PageModel + { + public void OnGet() + { + } + } +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Server.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Server.cshtml new file mode 100644 index 0000000..ec365b6 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Server.cshtml @@ -0,0 +1,101 @@ +@model V3ServerDefinitionViewModel +@{ + var server = this.Model.Server; + var serverAddress = $"{server.Host}{server.PathName}"; +} + +
+
+ +
+ @if (!string.IsNullOrWhiteSpace(server.Description)) + { +

@Html.Raw(Markdown.ToHtml(server.Description ?? string.Empty))

+ } + @if (server.Variables != null) + { +
+ +
+ + Variables +
+
+
+ + + @foreach (var variableKvp in server.Variables) + { + + + + + } + +
+ @variableKvp.Key + + @Html.Raw(Markdown.ToHtml(variableKvp.Value.Description ?? string.Empty)) + @if(variableKvp.Value.Enum != null && variableKvp.Value.Enum.Count > 0) + { + Supported values: @Html.Raw(string.Join(", ", variableKvp.Value.Enum.Select(v => $"{v}"))) + } +
+
+
+ } + @if (server.Security != null) + { +
+ +
+ @foreach (var securityRequirement in server.Security) + { + @* *@ + } +
+
+ } + @if(server.Bindings != null) + { +
+ +
+ @if (server.Bindings == null || !server.Bindings.AsEnumerable().Any()) + { +

No bindings defined.

+ } + else + { + @foreach (var binding in server.Bindings.AsEnumerable()) + { + + } + } +
+
+ } +
+
+
diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/_ViewImports.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/_ViewImports.cshtml index e7fd17c..ad74411 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/_ViewImports.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/_ViewImports.cshtml @@ -1,12 +1,14 @@ -@using Root_Namespace +@using Markdig @using Neuroglia @using Neuroglia.AsyncApi @using Neuroglia.AsyncApi.AspNetCore.UI.Models +@using Neuroglia.AsyncApi.AspNetCore.UI.Models.v2 +@using Neuroglia.AsyncApi.AspNetCore.UI.Models.v3 @using Neuroglia.AsyncApi.Generation @using Neuroglia.AsyncApi.v2 +@using Neuroglia.AsyncApi.v3 @using Neuroglia.Data.Schemas.Json @using Neuroglia.Serialization @using Json.Schema @using System.Text.Json.Serialization -@namespace Root_Namespace.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Usings.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Usings.cs index 017e4c0..298e415 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Usings.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Usings.cs @@ -12,5 +12,6 @@ // limitations under the License. global using Json.Schema; +global using Neuroglia.AsyncApi.Bindings; global using Neuroglia.AsyncApi.v2; -global using Neuroglia.Data.Schemas.Json; \ No newline at end of file +global using Neuroglia.AsyncApi.v3; diff --git a/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingMiddleware.cs b/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingMiddleware.cs index cd6a436..6b1c2f6 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingMiddleware.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingMiddleware.cs @@ -20,14 +20,14 @@ namespace Neuroglia.AsyncApi; /// -/// Represents the middleware used to serve s +/// Represents the middleware used to serve s /// /// /// Initializes a new /// /// The service used to access the current -/// The service used to provide s -/// The service used to write s +/// The service used to provide s +/// The service used to write s /// The the next in the pipeline public class AsyncApiDocumentServingMiddleware(IOptions options, IAsyncApiDocumentProvider documentProvider, IAsyncApiDocumentWriter documentWriter, RequestDelegate next) { @@ -53,9 +53,9 @@ public class AsyncApiDocumentServingMiddleware(IOptions - /// Gets a route/ mapping of the routes rendered based on the configured template for all available s + /// Gets a route/ mapping of the routes rendered based on the configured template for all available s ///
- protected virtual Dictionary DocumentRoutes { get; } = documentProvider.ToDictionary(d => d, options.Value.GenerateRoutesFor).SelectMany(kvp => kvp.Value.Select(r => new KeyValuePair(r, kvp.Key))).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); + protected virtual Dictionary DocumentRoutes { get; } = documentProvider.ToDictionary(d => d, options.Value.GenerateRoutesFor).SelectMany(kvp => kvp.Value.Select(r => new KeyValuePair(r, kvp.Key))).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); /// /// Invokes the @@ -93,12 +93,12 @@ public virtual async Task InvokeAsync(HttpContext context) protected virtual byte[] RenderAsyncApiDocumentList() { string html = $@"
    -{string.Join(Environment.NewLine, this.DocumentProvider.ToList().GroupBy(d => d.Info.Title).Select(dg => @$"
  • +{string.Join(Environment.NewLine, this.DocumentProvider.ToList().GroupBy(d => d.Title).Select(dg => @$"
  • {dg.Key}
  • "))} diff --git a/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingOptions.cs b/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingOptions.cs index 86849e8..a71eaa9 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingOptions.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore/AsyncApiDocumentServingOptions.cs @@ -11,19 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi; /// -/// Represents the options used to configure how to serve s +/// Represents the options used to configure how to serve s /// public class AsyncApiDocumentServingOptions { /// - /// Gets/sets the path prefix of s + /// Gets/sets the path prefix of s /// - public virtual string PathTemplate { get; set; } = "/asyncapi/{title}.{version}.[json|yaml]"; + public virtual string PathTemplate { get; set; } = "/asyncapi/{specVersion}/{title}/{version}/doc.[json|yaml]"; } diff --git a/src/Neuroglia.AsyncApi.AspNetCore/Extensions/AsyncApiDocumentServingOptionsExtensions.cs b/src/Neuroglia.AsyncApi.AspNetCore/Extensions/AsyncApiDocumentServingOptionsExtensions.cs index 3eab178..0c083ad 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore/Extensions/AsyncApiDocumentServingOptionsExtensions.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore/Extensions/AsyncApiDocumentServingOptionsExtensions.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi; /// @@ -22,19 +20,18 @@ public static class AsyncApiDocumentServingOptionsExtensions { /// - /// Generates routes for the specified + /// Generates routes for the specified /// /// The current - /// The to generate the routes for - /// A new containing the egenerated routes - public static IEnumerable GenerateRoutesFor(this AsyncApiDocumentServingOptions options, V2AsyncApiDocument document) + /// The to generate the routes for + /// A new containing the generated routes + public static IEnumerable GenerateRoutesFor(this AsyncApiDocumentServingOptions options, IAsyncApiDocument document) { ArgumentNullException.ThrowIfNull(options); ArgumentNullException.ThrowIfNull(document); #pragma warning disable CA2208 // Instantiate argument exceptions correctly if (string.IsNullOrWhiteSpace(options.PathTemplate)) throw new ArgumentNullException($"{nameof(AsyncApiDocumentServingOptions)}.{nameof(AsyncApiDocumentServingOptions.PathTemplate)}"); #pragma warning restore CA2208 // Instantiate argument exceptions correctly - yield return options.GenerateRouteFor(document, AsyncApiDocumentFormat.Json); yield return options.GenerateRouteFor(document, AsyncApiDocumentFormat.Yaml); } @@ -46,19 +43,19 @@ public static IEnumerable GenerateRoutesFor(this AsyncApiDocumentServing /// The to generate the route for /// The to generate the route for /// The generated route - public static string GenerateRouteFor(this AsyncApiDocumentServingOptions options, V2AsyncApiDocument document, AsyncApiDocumentFormat format) + public static string GenerateRouteFor(this AsyncApiDocumentServingOptions options, IAsyncApiDocument document, AsyncApiDocumentFormat format) { ArgumentNullException.ThrowIfNull(options); ArgumentNullException.ThrowIfNull(document); #pragma warning disable CA2208 // Instantiate argument exceptions correctly if (string.IsNullOrWhiteSpace(options.PathTemplate)) throw new ArgumentNullException($"{nameof(AsyncApiDocumentServingOptions)}.{nameof(AsyncApiDocumentServingOptions.PathTemplate)}"); #pragma warning restore CA2208 // Instantiate argument exceptions correctly - var result = StringFormatter.NamedFormat(options.PathTemplate, new { + specVersion = document.AsyncApi, id = document.Id?.ToKebabCase(), - title = document.Info.Title.ToKebabCase(), - version = document.Info.Version + title = document.Title.ToKebabCase(), + version = document.Version }); return result.Replace("[json|yaml]", format == AsyncApiDocumentFormat.Json ? "json" : "yaml"); diff --git a/src/Neuroglia.AsyncApi.AspNetCore/Neuroglia.AsyncApi.AspNetCore.csproj b/src/Neuroglia.AsyncApi.AspNetCore/Neuroglia.AsyncApi.AspNetCore.csproj index 71cc3d1..8994418 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore/Neuroglia.AsyncApi.AspNetCore.csproj +++ b/src/Neuroglia.AsyncApi.AspNetCore/Neuroglia.AsyncApi.AspNetCore.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable Library diff --git a/src/Neuroglia.AsyncApi.CloudEvents/Neuroglia.AsyncApi.CloudEvents.csproj b/src/Neuroglia.AsyncApi.CloudEvents/Neuroglia.AsyncApi.CloudEvents.csproj index 6ae9adb..eeef953 100644 --- a/src/Neuroglia.AsyncApi.CloudEvents/Neuroglia.AsyncApi.CloudEvents.csproj +++ b/src/Neuroglia.AsyncApi.CloudEvents/Neuroglia.AsyncApi.CloudEvents.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable True diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/AsyncApiAttribute.cs b/src/Neuroglia.AsyncApi.Core/Attributes/AsyncApiAttribute.cs index fa24cc0..3869729 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/AsyncApiAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/Attributes/AsyncApiAttribute.cs @@ -11,78 +11,64 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi; /// -/// Represents an used to mark a class as an Async Api to generate a new for +/// Represents an used to mark a class as an Async Api to generate a new for /// -[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] -public class AsyncApiAttribute +/// The 's title +/// The 's version +public abstract class AsyncApiAttribute(string title, string version) : Attribute { /// - /// Initializes a new - /// - /// The 's title - /// The 's version - public AsyncApiAttribute(string title, string version) - { - if (string.IsNullOrWhiteSpace(title)) throw new ArgumentNullException(nameof(title)); - if (string.IsNullOrWhiteSpace(version)) throw new ArgumentNullException(nameof(version)); - this.Title = title; - this.Version = version; - } - - /// - /// Gets/sets the generated 's id + /// Gets/sets the generated 's id /// public virtual string? Id { get; set; } /// - /// Gets the generated 's title + /// Gets the generated 's title /// - public virtual string Title { get; } + public virtual string Title { get; } = title; /// - /// Gets the generated 's version + /// Gets the generated 's version /// - public virtual string Version { get; } + public virtual string Version { get; } = version; /// - /// Gets/sets the generated 's description + /// Gets/sets the generated 's description /// public virtual string? Description { get; set; } /// - /// Gets/sets the generated 's terms of service + /// Gets/sets the generated 's terms of service /// public virtual string? TermsOfServiceUrl { get; set; } /// - /// Gets/sets the generated 's contact name + /// Gets/sets the generated 's contact name /// public virtual string? ContactName { get; set; } /// - /// Gets/sets the generated 's contact url + /// Gets/sets the generated 's contact url /// public virtual string? ContactUrl { get; set; } /// - /// Gets/sets the generated 's contact email + /// Gets/sets the generated 's contact email /// public virtual string? ContactEmail { get; set; } /// - /// Gets/sets the generated 's license name + /// Gets/sets the generated 's license name /// public virtual string? LicenseName { get; set; } /// - /// Gets/sets the generated 's license + /// Gets/sets the generated 's license /// public virtual string? LicenseUrl { get; set; } diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/TagAttribute.cs b/src/Neuroglia.AsyncApi.Core/Attributes/TagAttribute.cs deleted file mode 100644 index 0a797cb..0000000 --- a/src/Neuroglia.AsyncApi.Core/Attributes/TagAttribute.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright © 2021-Present Neuroglia SRL. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"), -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi; - -/// -/// Represents an used to tag an method -/// -[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] -public class TagAttribute - : Attribute -{ - - /// - /// Initializes a new - /// - /// The name of the to generate - /// The description of the to generate - public TagAttribute(string name, string? description) - { - if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); - this.Name = name; - this.Description = description; - } - - /// - /// Initializes a new - /// - /// The name of the to generate - public TagAttribute(string name) : this(name, null) { } - - /// - /// Gets the name of the to generate - /// - public virtual string Name { get; } - - /// - /// Gets the description of the to generate - /// - public virtual string? Description { get; set; } - -} diff --git a/src/Neuroglia.AsyncApi.Core/IAsyncApiDocument.cs b/src/Neuroglia.AsyncApi.Core/IAsyncApiDocument.cs index 16ff702..4f193f1 100644 --- a/src/Neuroglia.AsyncApi.Core/IAsyncApiDocument.cs +++ b/src/Neuroglia.AsyncApi.Core/IAsyncApiDocument.cs @@ -29,4 +29,19 @@ public interface IAsyncApiDocument /// string AsyncApi { get; } + /// + /// Gets the identifier of the application the AsyncAPI document is defining + /// + string? Id { get; } + + /// + /// Gets the document's title + /// + string Title { get; } + + /// + /// Gets the document's version + /// + string Version { get; } + } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/Neuroglia.AsyncApi.Core.csproj b/src/Neuroglia.AsyncApi.Core/Neuroglia.AsyncApi.Core.csproj index 07e44f1..72a96f3 100644 --- a/src/Neuroglia.AsyncApi.Core/Neuroglia.AsyncApi.Core.csproj +++ b/src/Neuroglia.AsyncApi.Core/Neuroglia.AsyncApi.Core.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable $(MSBuildProjectName.Replace(" ", "_").Replace(".Core", "")) diff --git a/src/Neuroglia.AsyncApi.Core/Usings.cs b/src/Neuroglia.AsyncApi.Core/Usings.cs index 570362e..ae9cffb 100644 --- a/src/Neuroglia.AsyncApi.Core/Usings.cs +++ b/src/Neuroglia.AsyncApi.Core/Usings.cs @@ -14,7 +14,6 @@ global using Json.Schema; global using Neuroglia.AsyncApi.Bindings; global using Neuroglia.Serialization.Json.Converters; -global using System.Collections; global using System.ComponentModel; global using System.ComponentModel.DataAnnotations; global using System.Runtime.Serialization; diff --git a/src/Neuroglia.AsyncApi.Core/v2/Attributes/AsyncApiV2Attribute.cs b/src/Neuroglia.AsyncApi.Core/v2/Attributes/AsyncApiV2Attribute.cs new file mode 100644 index 0000000..ffb6c66 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v2/Attributes/AsyncApiV2Attribute.cs @@ -0,0 +1,26 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v2; + +/// +/// Represents an used to mark a class as an Async Api to generate a new for +/// +/// The 's title +/// The 's version +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] +public class AsyncApiV2Attribute(string title, string version) + : AsyncApiAttribute(title, version) +{ + +} diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/ChannelAttribute.cs b/src/Neuroglia.AsyncApi.Core/v2/Attributes/ChannelV2Attribute.cs similarity index 53% rename from src/Neuroglia.AsyncApi.Core/Attributes/ChannelAttribute.cs rename to src/Neuroglia.AsyncApi.Core/v2/Attributes/ChannelV2Attribute.cs index 052edcf..96414ab 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/ChannelAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/Attributes/ChannelV2Attribute.cs @@ -11,44 +11,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi; +namespace Neuroglia.AsyncApi.v2; /// /// Represents an used to mark a class or a method as a /// +/// The 's name +/// The 's description [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] -public class ChannelAttribute +public class ChannelV2Attribute(string name, string? description = null) : Attribute { - - /// - /// Initializes a new - /// - /// The 's name - /// The 's description - public ChannelAttribute(string name, string? description) - { - if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); - this.Name = name; - this.Description = description; - } - - /// - /// Initializes a new - /// - /// The 's name - public ChannelAttribute(string name) : this(name, null) { } /// /// Gets the 's name /// - public virtual string Name { get; } + public virtual string Name { get; } = name; /// /// Gets/sets the 's description /// - public virtual string? Description { get; set; } + public virtual string? Description { get; set; } = description; } diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/MessageAttribute.cs b/src/Neuroglia.AsyncApi.Core/v2/Attributes/MessageV2Attribute.cs similarity index 94% rename from src/Neuroglia.AsyncApi.Core/Attributes/MessageAttribute.cs rename to src/Neuroglia.AsyncApi.Core/v2/Attributes/MessageV2Attribute.cs index a5b5387..d62e8b0 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/MessageAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/Attributes/MessageV2Attribute.cs @@ -11,18 +11,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi; +namespace Neuroglia.AsyncApi.v2; /// /// Represents an used to configure an 's /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)] -public class MessageAttribute +public class MessageV2Attribute : Attribute { - + /// /// Gets/sets the 's name /// diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/OperationAttribute.cs b/src/Neuroglia.AsyncApi.Core/v2/Attributes/OperationV2Attribute.cs similarity index 84% rename from src/Neuroglia.AsyncApi.Core/Attributes/OperationAttribute.cs rename to src/Neuroglia.AsyncApi.Core/v2/Attributes/OperationV2Attribute.cs index 1f327f9..dbb9b3c 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/OperationAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/Attributes/OperationV2Attribute.cs @@ -11,28 +11,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi; +namespace Neuroglia.AsyncApi.v2; /// /// Represents an used to mark a method as an /// /// -/// Initializes a new +/// Initializes a new /// /// The 's type /// The 's message type [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] -public abstract class OperationAttribute(V2OperationType operationType, Type? messageType) +public abstract class OperationV2Attribute(V2OperationType operationType, Type? messageType) : Attribute { /// - /// Initializes a new + /// Initializes a new /// /// The 's type - protected OperationAttribute(V2OperationType operationType) : this(operationType, null) { } + protected OperationV2Attribute(V2OperationType operationType) : this(operationType, null) { } /// /// Gets the 's type diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/PublishOperationAttribute.cs b/src/Neuroglia.AsyncApi.Core/v2/Attributes/PublishOperationV2Attribute.cs similarity index 69% rename from src/Neuroglia.AsyncApi.Core/Attributes/PublishOperationAttribute.cs rename to src/Neuroglia.AsyncApi.Core/v2/Attributes/PublishOperationV2Attribute.cs index 878fe5d..7c31419 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/PublishOperationAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/Attributes/PublishOperationV2Attribute.cs @@ -11,26 +11,24 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi; +namespace Neuroglia.AsyncApi.v2; /// /// Represents an used to mark a method as an of type /// -public class PublishOperationAttribute - : OperationAttribute +public class PublishOperationV2Attribute + : OperationV2Attribute { /// - /// Initializes a new + /// Initializes a new /// /// The 's message type - public PublishOperationAttribute(Type messageType) : base(V2OperationType.Publish, messageType) { } + public PublishOperationV2Attribute(Type messageType) : base(V2OperationType.Publish, messageType) { } /// - /// Initializes a new + /// Initializes a new /// - public PublishOperationAttribute() : base(V2OperationType.Publish) { } + public PublishOperationV2Attribute() : base(V2OperationType.Publish) { } } diff --git a/src/Neuroglia.AsyncApi.Core/Attributes/SubscribeOperationAttribute.cs b/src/Neuroglia.AsyncApi.Core/v2/Attributes/SubscribeOperationV2Attribute.cs similarity index 68% rename from src/Neuroglia.AsyncApi.Core/Attributes/SubscribeOperationAttribute.cs rename to src/Neuroglia.AsyncApi.Core/v2/Attributes/SubscribeOperationV2Attribute.cs index eb63453..308ff1b 100644 --- a/src/Neuroglia.AsyncApi.Core/Attributes/SubscribeOperationAttribute.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/Attributes/SubscribeOperationV2Attribute.cs @@ -11,26 +11,24 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi; +namespace Neuroglia.AsyncApi.v2; /// /// Represents an used to mark a method as an of type /// -public class SubscribeOperationAttribute - : OperationAttribute +public class SubscribeOperationV2Attribute + : OperationV2Attribute { - + /// - /// Initializes a new + /// Initializes a new /// /// The 's message type - public SubscribeOperationAttribute(Type messageType) : base(V2OperationType.Subscribe, messageType) { } + public SubscribeOperationV2Attribute(Type messageType) : base(V2OperationType.Subscribe, messageType) { } /// - /// Initializes a new + /// Initializes a new /// - public SubscribeOperationAttribute() : base(V2OperationType.Subscribe) { } + public SubscribeOperationV2Attribute() : base(V2OperationType.Subscribe) { } } diff --git a/src/Neuroglia.AsyncApi.Core/v2/Attributes/TagV2Attribute.cs b/src/Neuroglia.AsyncApi.Core/v2/Attributes/TagV2Attribute.cs new file mode 100644 index 0000000..613f037 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v2/Attributes/TagV2Attribute.cs @@ -0,0 +1,36 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v2; + +/// +/// Represents an used to tag an Async API component +/// +/// The name of the to generate +/// The description of the to generate +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] +public class TagV2Attribute(string name, string? description = null) + : Attribute +{ + + /// + /// Gets the name of the to generate + /// + public virtual string Name { get; } = name; + + /// + /// Gets the description of the to generate + /// + public virtual string? Description { get; set; } = description; + +} diff --git a/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs b/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs index d78c5a8..d4c9cb6 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs @@ -115,6 +115,10 @@ public virtual bool TryGetOperation(string operationId, out V2OperationDefinitio return TryGetOperation(operationId, out operation, out _); } + string IAsyncApiDocument.Title => this.Info.Title; + + string IAsyncApiDocument.Version => this.Info.Version; + /// public override string? ToString() => this.Info == null || string.IsNullOrWhiteSpace(this.Info.Title) ? Id : this.Info?.Title; diff --git a/src/Neuroglia.AsyncApi.Core/v3/Attributes/AsyncApiV3Attribute.cs b/src/Neuroglia.AsyncApi.Core/v3/Attributes/AsyncApiV3Attribute.cs new file mode 100644 index 0000000..27365f9 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/Attributes/AsyncApiV3Attribute.cs @@ -0,0 +1,26 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an used to mark a class as an Async Api to generate a new for +/// +/// The 's title +/// The 's version +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] +public class AsyncApiV3Attribute(string title, string version) + : AsyncApiAttribute(title, version) +{ + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelParameterV3Attribute.cs b/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelParameterV3Attribute.cs new file mode 100644 index 0000000..063c02a --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelParameterV3Attribute.cs @@ -0,0 +1,56 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an used to define a +/// +/// The channel the applies to +/// The 's name +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Property, AllowMultiple = true)] +public class ChannelParameterV3Attribute(string channel, string name) + : Attribute +{ + + /// + /// Gets/sets the channel the applies to + /// + public string Channel { get; init; } = channel; + + /// + /// Gets/sets the 's name + /// + public string Name { get; init; } = name; + + /// + /// Gets/sets the 's description + /// + public string? Description { get; init; } + + /// + /// Gets/sets the 's enum values, if any + /// + public string[]? Enum { get; init; } + + /// + /// Gets/sets the 's default value, if any + /// + public string? Default { get; init; } + + /// + /// Gets/sets the 's location + /// + public string? Location { get; init; } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelV3Attribute.cs b/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelV3Attribute.cs new file mode 100644 index 0000000..24616fe --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelV3Attribute.cs @@ -0,0 +1,65 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an used to define a +/// +/// The 's name +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Property, AllowMultiple = true)] +public class ChannelV3Attribute(string name) + : Attribute +{ + + /// + /// Gets/sets the 's name + /// + public string Name { get; init; } = name; + + /// + /// Gets/sets the 's address + /// + public string? Address { get; init; } + + /// + /// Gets/sets the 's title + /// + public string? Title { get; init; } + + /// + /// Gets/sets the 's summary + /// + public string? Summary { get; init; } + + /// + /// Gets/sets the 's description + /// + public string? Description { get; init; } + + /// + /// Gets/sets an array containing the references to the 's parameters + /// + public string[]? Parameters { get; init; } + + /// + /// Gets/sets references to the servers the in which the channel is available + /// + public string[]? Servers { get; init; } + + /// + /// Gets/sets the url at which to get the 's external documentation, if any + /// + public virtual Uri? ExternalDocumentationUrl { get; init; } + +} diff --git a/src/Neuroglia.AsyncApi.Core/v3/Attributes/MessageV3Attribute.cs b/src/Neuroglia.AsyncApi.Core/v3/Attributes/MessageV3Attribute.cs new file mode 100644 index 0000000..821287b --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/Attributes/MessageV3Attribute.cs @@ -0,0 +1,54 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an used to configure an 's +/// +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)] +public class MessageV3Attribute + : Attribute +{ + + /// + /// Gets/sets the 's name + /// + public virtual string? Name { get; set; } + + /// + /// Gets/sets the 's title + /// + public virtual string? Title { get; set; } + + /// + /// Gets/sets the 's description + /// + public virtual string? Description { get; set; } + + /// + /// Gets/sets the 's summary + /// + public virtual string? Summary { get; set; } + + /// + /// Gets/sets the 's content type + /// + public virtual string? ContentType { get; set; } + + /// + /// Gets/sets the url at which to get the 's external documentation, if any + /// + public virtual Uri? ExternalDocumentationUrl { get; init; } + +} diff --git a/src/Neuroglia.AsyncApi.Core/v3/Attributes/OperationV3Attribute.cs b/src/Neuroglia.AsyncApi.Core/v3/Attributes/OperationV3Attribute.cs new file mode 100644 index 0000000..ec9ee38 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/Attributes/OperationV3Attribute.cs @@ -0,0 +1,62 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an used to mark a method as a +/// +/// The 's name +/// The 's action +/// A reference to the channel the belongs to +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] +public class OperationV3Attribute(string name, V3OperationAction action, string channel) + : Attribute +{ + + /// + /// Gets the 's name + /// + public string Name { get; } = name; + + /// + /// Gets the 's action + /// + public V3OperationAction Action { get; } = action; + + /// + /// Gets a reference to the channel the belongs to + /// + public string Channel { get; } = channel; + + /// + /// Gets/sets the 's title + /// + public virtual string? Title { get; init; } + + /// + /// Gets/sets the 's summary + /// + public virtual string? Summary { get; init; } + + /// + /// Gets/sets the 's summary + /// + public virtual string? Description { get; init; } + + /// + /// Gets/sets the url at which to get the 's external documentation, if any + /// + public virtual Uri? ExternalDocumentationUrl { get; init; } + +} diff --git a/src/Neuroglia.AsyncApi.Core/v3/Attributes/TagV3Attribute.cs b/src/Neuroglia.AsyncApi.Core/v3/Attributes/TagV3Attribute.cs new file mode 100644 index 0000000..fd85d91 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/Attributes/TagV3Attribute.cs @@ -0,0 +1,39 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an used to tag an Async API component +/// +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] +public class TagV3Attribute + : Attribute +{ + + /// + /// Gets a reference to the to use + /// + public virtual string? Reference { get; init; } + + /// + /// Gets the name of the to generate + /// + public virtual string? Name { get; init; } + + /// + /// Gets the description of the to generate + /// + public virtual string? Description { get; init; } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs b/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs index 8940877..6fb69d4 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3AsyncApiDocument.cs @@ -80,6 +80,10 @@ public record V3AsyncApiDocument [DataMember(Order = 8, Name = "components"), JsonPropertyOrder(8), JsonPropertyName("components"), YamlMember(Order = 8, Alias = "components")] public virtual V3ComponentDefinitionCollection? Components { get; set; } + string IAsyncApiDocument.Title => this.Info.Title; + + string IAsyncApiDocument.Version => this.Info.Version; + /// public override string? ToString() => this.Info == null || string.IsNullOrWhiteSpace(this.Info.Title) ? Id : this.Info?.Title; diff --git a/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/IServiceCollectionExtensions.cs b/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/IServiceCollectionExtensions.cs index b07ee43..6bb299c 100644 --- a/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/IServiceCollectionExtensions.cs +++ b/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/IServiceCollectionExtensions.cs @@ -16,7 +16,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; using Neuroglia.AsyncApi.FluentBuilders.v2; -using Neuroglia.AsyncApi.FluentBuilders.v2; +using Neuroglia.AsyncApi.FluentBuilders.v3; using Neuroglia.AsyncApi.Generation; using Neuroglia.AsyncApi.IO; using Neuroglia.AsyncApi.v2; @@ -44,6 +44,7 @@ public static IServiceCollection AddAsyncApi(this IServiceCollection services) services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddTransient(); + services.TryAddTransient(); services.AddValidatorsFromAssemblyContaining(ServiceLifetime.Transient); return services; } diff --git a/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/Neuroglia.AsyncApi.DependencyInjectionExtensions.csproj b/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/Neuroglia.AsyncApi.DependencyInjectionExtensions.csproj index dca18c6..945c006 100644 --- a/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/Neuroglia.AsyncApi.DependencyInjectionExtensions.csproj +++ b/src/Neuroglia.AsyncApi.DependencyInjectionExtensions/Neuroglia.AsyncApi.DependencyInjectionExtensions.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable True diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Neuroglia.AsyncApi.FluentBuilders.csproj b/src/Neuroglia.AsyncApi.FluentBuilders/Neuroglia.AsyncApi.FluentBuilders.csproj index 2487f96..ea2021d 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Neuroglia.AsyncApi.FluentBuilders.csproj +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Neuroglia.AsyncApi.FluentBuilders.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable True diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerationOptions.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerationOptions.cs index c206404..3f9edb7 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerationOptions.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerationOptions.cs @@ -11,13 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.FluentBuilders.v2; -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.Generation; /// -/// Represents the options used to configure generation +/// Represents the options used to configure generation /// public class AsyncApiDocumentGenerationOptions { @@ -25,7 +22,12 @@ public class AsyncApiDocumentGenerationOptions /// /// Gets/sets an used to configure the s to configure /// - public Action? DefaultConfiguration { get; set; } + public Action? V2BuilderSetup { get; set; } + + /// + /// Gets/sets an used to configure the s to configure + /// + public Action? V3BuilderSetup { get; set; } /// /// Gets/sets a boolean indicating whether or not the automatically generate examples. Defaults to true. diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.cs index 9e9b2df..091bb77 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.cs @@ -11,20 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.FluentBuilders.v2; -using Neuroglia.Data.Schemas.Json; - namespace Neuroglia.AsyncApi.Generation; /// /// Represents the default implementation of the interface /// -/// -/// Initializes a new -/// /// The current /// The service used to generate example values based on a JSON Schema -public class AsyncApiDocumentGenerator(IServiceProvider serviceProvider, IJsonSchemaExampleGenerator exampleGenerator) +public partial class AsyncApiDocumentGenerator(IServiceProvider serviceProvider, IJsonSchemaExampleGenerator exampleGenerator) : IAsyncApiDocumentGenerator { @@ -39,159 +33,19 @@ public class AsyncApiDocumentGenerator(IServiceProvider serviceProvider, IJsonSc protected IJsonSchemaExampleGenerator ExampleGenerator { get; } = exampleGenerator; /// - public virtual async Task> GenerateAsync(IEnumerable markupTypes, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) + public virtual async Task> GenerateAsync(IEnumerable markupTypes, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(markupTypes); - var types = markupTypes .Select(t => t.Assembly) .Distinct() - .SelectMany(t => t.GetTypes()).Where(t => t.GetCustomAttribute() != null); - var documents = new List(types.Count()); - foreach (var type in types) documents.Add(await this.GenerateDocumentForAsync(type, options, cancellationToken).ConfigureAwait(false)); - + .SelectMany(t => t.GetTypes()).Where(t => t.GetCustomAttribute() != null || t.GetCustomAttribute() != null); + var v2ApiTypes = types.Where(t => t.GetCustomAttribute() != null); + var v3ApiTypes = types.Where(t => t.GetCustomAttribute() != null); + var documents = new List(types.Count()); + foreach (var type in v2ApiTypes) documents.Add(await this.GenerateV2DocumentForAsync(type, options, cancellationToken).ConfigureAwait(false)); + foreach (var type in v3ApiTypes) documents.Add(await this.GenerateV3DocumentForAsync(type, options, cancellationToken).ConfigureAwait(false)); return documents; } - /// - /// Generates a new for the specified type - /// - /// The type to generate a code-first for - /// The to use - /// A - /// A new - protected virtual async Task GenerateDocumentForAsync(Type type, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) - { - ArgumentNullException.ThrowIfNull(type); - - var asyncApi = type.GetCustomAttribute() ?? throw new ArgumentException($"The specified type '{type.Name}' is not marked with the {nameof(AsyncApiAttribute)}", nameof(type)); - var builder = this.ServiceProvider.GetRequiredService(); - options.DefaultConfiguration?.Invoke(builder); - builder - .WithId(asyncApi.Id!) - .WithTitle(asyncApi.Title) - .WithVersion(asyncApi.Version); - if (!string.IsNullOrWhiteSpace(asyncApi.Description)) builder.WithDescription(asyncApi.Description); - if (!string.IsNullOrWhiteSpace(asyncApi.LicenseName) && !string.IsNullOrWhiteSpace(asyncApi.LicenseUrl)) builder.WithLicense(asyncApi.LicenseName, new Uri(asyncApi.LicenseUrl, UriKind.RelativeOrAbsolute)); - if (!string.IsNullOrWhiteSpace(asyncApi.TermsOfServiceUrl)) builder.WithTermsOfService(new Uri(asyncApi.TermsOfServiceUrl, UriKind.RelativeOrAbsolute)); - if (!string.IsNullOrWhiteSpace(asyncApi.ContactName)) builder.WithContact(asyncApi.ContactName, string.IsNullOrWhiteSpace(asyncApi.ContactUrl) ? null : new Uri(asyncApi.ContactUrl, UriKind.RelativeOrAbsolute), asyncApi.ContactEmail); - foreach (var operationsPerChannel in type.GetMethods(BindingFlags.Default | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy) - .Where(m => m.GetCustomAttribute() != null && m.GetCustomAttribute() != null) - .GroupBy(m => m.GetCustomAttribute()!.Name)) - { - var channel = operationsPerChannel.First().GetCustomAttribute()!; - await ConfigureChannelForAsync(builder, channel, [.. operationsPerChannel], options, cancellationToken).ConfigureAwait(false); - } - return builder.Build(); - } - - /// - /// Builds a new - /// - /// The to configure - /// The attribute used to describe the to configure - /// A containing the 's s s - /// The to use - /// A - /// A new awaitable - protected virtual async Task ConfigureChannelForAsync(IV2AsyncApiDocumentBuilder builder, ChannelAttribute channel, List methods, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) - { - ArgumentNullException.ThrowIfNull(builder); - ArgumentNullException.ThrowIfNull(channel); - ArgumentNullException.ThrowIfNull(methods); - - builder.WithChannel(channel.Name, channelBuilder => - { - channelBuilder.WithDescription(channel.Description!); - foreach (var method in methods) - { - var operation = method.GetCustomAttribute()!; - channelBuilder.WithOperation(operation.OperationType, operationBuilder => - { - var operationId = operation.OperationId; - if (string.IsNullOrWhiteSpace(operationId)) operationId = (method.Name.EndsWith("Async") ? method.Name[..^5] : method.Name).ToCamelCase(); - var description = operation.Description; - if (string.IsNullOrWhiteSpace(description)) description = XmlDocumentationHelper.SummaryOf(method); - var summary = operation.Summary; - if (string.IsNullOrWhiteSpace(summary)) summary = description; - operationBuilder - .WithOperationId(operationId) - .WithDescription(description!) - .WithSummary(summary!); - foreach (var tag in method.GetCustomAttributes()) operationBuilder.WithTag(tagBuilder => tagBuilder.WithName(tag.Name).WithDescription(tag.Description!)); - operationBuilder.WithMessage(messageBuilder => this.ConfigureOperationMessageFor(messageBuilder, operation, method, options)); - }); - } - }); - await Task.CompletedTask; - } - - /// - /// Configures and builds a new for the specified - /// - /// The to configure - /// The attribute used to describe the to configure - /// The marked with the specified attribute - /// The to use - protected virtual void ConfigureOperationMessageFor(IV2MessageDefinitionBuilder messageBuilder, OperationAttribute operation, MethodInfo operationMethod, AsyncApiDocumentGenerationOptions options) - { - ArgumentNullException.ThrowIfNull(messageBuilder); - ArgumentNullException.ThrowIfNull(operation); - ArgumentNullException.ThrowIfNull(operationMethod); - - var messageType = operation.MessageType; - var parameters = operationMethod.GetParameters(); - JsonSchema messageSchema; - if (messageType == null) - { - if (parameters.Length == 1 || parameters.Length == 2 && parameters[1].ParameterType == typeof(CancellationToken)) - { - messageType = parameters.First().ParameterType; - messageSchema = new JsonSchemaBuilder().FromType(parameters.First().ParameterType, JsonSchemaGeneratorConfiguration.Default); - } - else - { - var messageSchemaBuilder = new JsonSchemaBuilder(); - var messageSchemaProperties = new Dictionary(); - var requiredProperties = new List(); - messageType = typeof(object); - foreach (var parameter in parameters) - { - if (parameter.TryGetCustomAttribute(out _)) continue; - var parameterSchema = messageSchemaBuilder.FromType(parameter.ParameterType, JsonSchemaGeneratorConfiguration.Default); - messageSchemaProperties.Add(parameter.Name!, parameterSchema); - if (parameter.TryGetCustomAttribute(out _)|| !parameter.ParameterType.IsNullable()|| parameter.DefaultValue == DBNull.Value) requiredProperties.Add(parameter.Name!); - } - messageSchemaBuilder.Properties(messageSchemaProperties); - messageSchemaBuilder.Required(requiredProperties); - messageSchema = messageSchemaBuilder.Build(); - } - } - else messageSchema = new JsonSchemaBuilder().FromType(messageType, JsonSchemaGeneratorConfiguration.Default); - messageBuilder.WithPayloadSchema(messageSchema); - var message = operationMethod.GetCustomAttribute(); - message ??= messageType?.GetCustomAttribute(); - var name = message?.Name; - if (string.IsNullOrWhiteSpace(name)) name = messageType?.Name.ToCamelCase(); - var title = message?.Title; - if (string.IsNullOrWhiteSpace(title)) title = name?.SplitCamelCase(false, true); - var description = message?.Description; - if (string.IsNullOrWhiteSpace(description)) description = messageType == null ? null : XmlDocumentationHelper.SummaryOf(messageType); - var summary = message?.Summary; - if (string.IsNullOrWhiteSpace(summary)) summary = description; - var contentType = message?.ContentType; - messageBuilder - .WithName(name!) - .WithTitle(title!) - .WithSummary(summary!) - .WithDescription(description!) - .WithContentType(contentType!); - if(messageType != null) foreach (var tag in messageType.GetCustomAttributes()) messageBuilder.WithTag(tagBuilder => tagBuilder.WithName(tag.Name).WithDescription(tag.Description!)); - if (options == null || options.AutomaticallyGenerateExamples) - { - messageBuilder.WithExample("Minimal", this.ExampleGenerator.GenerateExample(messageSchema, requiredPropertiesOnly: true)!); - messageBuilder.WithExample("Extended", this.ExampleGenerator.GenerateExample(messageSchema, requiredPropertiesOnly: false)!); - } - } - } diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v2.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v2.cs new file mode 100644 index 0000000..9fde73e --- /dev/null +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v2.cs @@ -0,0 +1,162 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.Data.Schemas.Json; + +namespace Neuroglia.AsyncApi.Generation; + +public partial class AsyncApiDocumentGenerator +{ + + /// + /// Generates a new for the specified type + /// + /// The type to generate a code-first for + /// The to use + /// A + /// A new + protected virtual async Task GenerateV2DocumentForAsync(Type type, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) + { + ArgumentNullException.ThrowIfNull(type); + ArgumentNullException.ThrowIfNull(options); + var asyncApi = type.GetCustomAttribute() ?? throw new ArgumentException($"The specified type '{type.Name}' is not marked with the {nameof(AsyncApiV2Attribute)}", nameof(type)); + var builder = ServiceProvider.GetRequiredService(); + options.V2BuilderSetup?.Invoke(builder); + builder + .WithId(asyncApi.Id!) + .WithTitle(asyncApi.Title) + .WithVersion(asyncApi.Version); + if (!string.IsNullOrWhiteSpace(asyncApi.Description)) builder.WithDescription(asyncApi.Description); + if (!string.IsNullOrWhiteSpace(asyncApi.LicenseName) && !string.IsNullOrWhiteSpace(asyncApi.LicenseUrl)) builder.WithLicense(asyncApi.LicenseName, new Uri(asyncApi.LicenseUrl, UriKind.RelativeOrAbsolute)); + if (!string.IsNullOrWhiteSpace(asyncApi.TermsOfServiceUrl)) builder.WithTermsOfService(new Uri(asyncApi.TermsOfServiceUrl, UriKind.RelativeOrAbsolute)); + if (!string.IsNullOrWhiteSpace(asyncApi.ContactName)) builder.WithContact(asyncApi.ContactName, string.IsNullOrWhiteSpace(asyncApi.ContactUrl) ? null : new Uri(asyncApi.ContactUrl, UriKind.RelativeOrAbsolute), asyncApi.ContactEmail); + foreach (var operationsPerChannel in type.GetMethods(BindingFlags.Default | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy) + .Where(m => m.GetCustomAttribute() != null && m.GetCustomAttribute() != null) + .GroupBy(m => m.GetCustomAttribute()!.Name)) + { + var channel = operationsPerChannel.First().GetCustomAttribute()!; + await this.ConfigureV2ChannelForAsync(builder, channel, [.. operationsPerChannel], options, cancellationToken).ConfigureAwait(false); + } + return builder.Build(); + } + + /// + /// Builds a new + /// + /// The to configure + /// The attribute used to describe the to configure + /// A containing the 's s s + /// The to use + /// A + /// A new awaitable + protected virtual async Task ConfigureV2ChannelForAsync(IV2AsyncApiDocumentBuilder builder, ChannelV2Attribute channel, List methods, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) + { + ArgumentNullException.ThrowIfNull(builder); + ArgumentNullException.ThrowIfNull(channel); + ArgumentNullException.ThrowIfNull(methods); + + builder.WithChannel(channel.Name, channelBuilder => + { + channelBuilder.WithDescription(channel.Description!); + foreach (var method in methods) + { + var operation = method.GetCustomAttribute()!; + channelBuilder.WithOperation(operation.OperationType, operationBuilder => + { + var operationId = operation.OperationId; + if (string.IsNullOrWhiteSpace(operationId)) operationId = (method.Name.EndsWith("Async") ? method.Name[..^5] : method.Name).ToCamelCase(); + var description = operation.Description; + if (string.IsNullOrWhiteSpace(description)) description = XmlDocumentationHelper.SummaryOf(method); + var summary = operation.Summary; + if (string.IsNullOrWhiteSpace(summary)) summary = description; + operationBuilder + .WithOperationId(operationId) + .WithDescription(description!) + .WithSummary(summary!); + foreach (var tag in method.GetCustomAttributes()) operationBuilder.WithTag(tagBuilder => tagBuilder.WithName(tag.Name).WithDescription(tag.Description!)); + operationBuilder.WithMessage(messageBuilder => this.ConfigureV2OperationMessageFor(messageBuilder, operation, method, options)); + }); + } + }); + await Task.CompletedTask; + } + + /// + /// Configures and builds a new for the specified + /// + /// The to configure + /// The attribute used to describe the to configure + /// The marked with the specified attribute + /// The to use + protected virtual void ConfigureV2OperationMessageFor(IV2MessageDefinitionBuilder messageBuilder, OperationV2Attribute operation, MethodInfo operationMethod, AsyncApiDocumentGenerationOptions options) + { + ArgumentNullException.ThrowIfNull(messageBuilder); + ArgumentNullException.ThrowIfNull(operation); + ArgumentNullException.ThrowIfNull(operationMethod); + + var messageType = operation.MessageType; + var parameters = operationMethod.GetParameters(); + JsonSchema messageSchema; + if (messageType == null) + { + if (parameters.Length == 1 || parameters.Length == 2 && parameters[1].ParameterType == typeof(CancellationToken)) + { + messageType = parameters.First().ParameterType; + messageSchema = new JsonSchemaBuilder().FromType(parameters.First().ParameterType, JsonSchemaGeneratorConfiguration.Default); + } + else + { + var messageSchemaBuilder = new JsonSchemaBuilder(); + var messageSchemaProperties = new Dictionary(); + var requiredProperties = new List(); + messageType = typeof(object); + foreach (var parameter in parameters) + { + if (parameter.TryGetCustomAttribute(out _)) continue; + var parameterSchema = messageSchemaBuilder.FromType(parameter.ParameterType, JsonSchemaGeneratorConfiguration.Default); + messageSchemaProperties.Add(parameter.Name!, parameterSchema); + if (parameter.TryGetCustomAttribute(out _) || !parameter.ParameterType.IsNullable() || parameter.DefaultValue == DBNull.Value) requiredProperties.Add(parameter.Name!); + } + messageSchemaBuilder.Properties(messageSchemaProperties); + messageSchemaBuilder.Required(requiredProperties); + messageSchema = messageSchemaBuilder.Build(); + } + } + else messageSchema = new JsonSchemaBuilder().FromType(messageType, JsonSchemaGeneratorConfiguration.Default); + messageBuilder.WithPayloadSchema(messageSchema); + var message = operationMethod.GetCustomAttribute(); + message ??= messageType?.GetCustomAttribute(); + var name = message?.Name; + if (string.IsNullOrWhiteSpace(name)) name = messageType?.Name.ToCamelCase(); + var title = message?.Title; + if (string.IsNullOrWhiteSpace(title)) title = name?.SplitCamelCase(false, true); + var description = message?.Description; + if (string.IsNullOrWhiteSpace(description)) description = messageType == null ? null : XmlDocumentationHelper.SummaryOf(messageType); + var summary = message?.Summary; + if (string.IsNullOrWhiteSpace(summary)) summary = description; + var contentType = message?.ContentType; + messageBuilder + .WithName(name!) + .WithTitle(title!) + .WithSummary(summary!) + .WithDescription(description!) + .WithContentType(contentType!); + if (messageType != null) foreach (var tag in messageType.GetCustomAttributes()) messageBuilder.WithTag(tagBuilder => tagBuilder.WithName(tag.Name).WithDescription(tag.Description!)); + if (options == null || options.AutomaticallyGenerateExamples) + { + messageBuilder.WithExample("Minimal", ExampleGenerator.GenerateExample(messageSchema, requiredPropertiesOnly: true)!); + messageBuilder.WithExample("Extended", ExampleGenerator.GenerateExample(messageSchema, requiredPropertiesOnly: false)!); + } + } + +} diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v3.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v3.cs new file mode 100644 index 0000000..c933f3d --- /dev/null +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v3.cs @@ -0,0 +1,181 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.Generation; + +public partial class AsyncApiDocumentGenerator +{ + + /// + /// Generates a new for the specified type + /// + /// The type to generate a code-first for + /// The to use + /// A + /// A new + protected virtual async Task GenerateV3DocumentForAsync(Type type, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) + { + ArgumentNullException.ThrowIfNull(type); + ArgumentNullException.ThrowIfNull(options); + var asyncApi = type.GetCustomAttribute() ?? throw new ArgumentException($"The specified type '{type.Name}' is not marked with the {nameof(AsyncApiV3Attribute)}", nameof(type)); + var builder = this.ServiceProvider.GetRequiredService(); + options.V3BuilderSetup?.Invoke(builder); + builder + .WithId(asyncApi.Id!) + .WithTitle(asyncApi.Title) + .WithVersion(asyncApi.Version); + if (!string.IsNullOrWhiteSpace(asyncApi.Description)) builder.WithDescription(asyncApi.Description); + if (!string.IsNullOrWhiteSpace(asyncApi.LicenseName) && !string.IsNullOrWhiteSpace(asyncApi.LicenseUrl)) builder.WithLicense(asyncApi.LicenseName, new Uri(asyncApi.LicenseUrl, UriKind.RelativeOrAbsolute)); + if (!string.IsNullOrWhiteSpace(asyncApi.TermsOfServiceUrl)) builder.WithTermsOfService(new Uri(asyncApi.TermsOfServiceUrl, UriKind.RelativeOrAbsolute)); + if (!string.IsNullOrWhiteSpace(asyncApi.ContactName)) builder.WithContact(asyncApi.ContactName, string.IsNullOrWhiteSpace(asyncApi.ContactUrl) ? null : new Uri(asyncApi.ContactUrl, UriKind.RelativeOrAbsolute), asyncApi.ContactEmail); + foreach(var channel in type.GetCustomAttributes()) + { + await this.GenerateV3ChannelForAsync(builder, channel, options, cancellationToken); + } + foreach (var method in type.GetMethods(BindingFlags.Default | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy).Where(m => m.GetCustomAttribute() != null)) + { + var operation = method.GetCustomAttribute()!; + await this.GenerateV3OperationForAsync(builder, operation, method, options, cancellationToken); + } + return builder.Build(); + } + + /// + /// Builds a new + /// + /// The to configure + /// The attribute used to describe the to configure + /// The to use + /// A + /// A new awaitable + protected virtual Task GenerateV3ChannelForAsync(IV3AsyncApiDocumentBuilder document, ChannelV3Attribute channelAttribute, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) + { + ArgumentNullException.ThrowIfNull(document); + ArgumentNullException.ThrowIfNull(channelAttribute); + ArgumentNullException.ThrowIfNull(options); + document.WithChannel(channelAttribute.Name, channel => + { + channel + .WithAddress(channelAttribute.Address) + .WithTitle(channelAttribute.Title) + .WithSummary(channelAttribute.Summary) + .WithDescription(channelAttribute.Description); + if (channelAttribute.Servers != null) + { + foreach (var server in channelAttribute.Servers) + { + channel.WithServer(server); + } + } + if (channelAttribute?.ExternalDocumentationUrl != null) + { + channel.WithExternalDocumentation(doc => doc.WithUrl(channelAttribute.ExternalDocumentationUrl)); + } + }); + return Task.CompletedTask; + } + + /// + /// Builds a new + /// + /// The to configure + /// The attribute used to describe the to configure + /// The s s + /// The to use + /// A + /// A new awaitable + protected virtual Task GenerateV3OperationForAsync(IV3AsyncApiDocumentBuilder document, OperationV3Attribute operationAttribute, MethodInfo operationMethod, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) + { + ArgumentNullException.ThrowIfNull(document); + ArgumentNullException.ThrowIfNull(operationAttribute); + ArgumentNullException.ThrowIfNull(operationMethod); + ArgumentNullException.ThrowIfNull(options); + var operationParameters = operationMethod.GetParameters().Where(p => p.ParameterType != typeof(CancellationToken)).ToList(); + var requestMessageType = operationParameters.Count == 1 ? operationParameters[0].ParameterType : null; + var requestMessageAttribute = operationMethod.GetCustomAttribute(); + JsonSchema? requestMessagePayloadSchema = null; + var schemaGeneratorConfiguration = new SchemaGeneratorConfiguration() + { + PropertyNameResolver = PropertyNameResolvers.CamelCase, + Optimize = false + }; + schemaGeneratorConfiguration.Generators.Add(new DateTimeOffsetJsonSchemaGenerator()); + schemaGeneratorConfiguration.Refiners.Add(new XmlDocumentationJsonSchemaRefiner()); + if (requestMessageType == null) + { + var schemaBuilder = new JsonSchemaBuilder(); + var messageSchemaProperties = new Dictionary(); + var requiredProperties = new List(); + requestMessageType = typeof(object); + foreach (var parameter in operationParameters) + { + if (parameter.TryGetCustomAttribute(out _)) continue; + var parameterSchema = schemaBuilder.FromType(parameter.ParameterType, schemaGeneratorConfiguration); + messageSchemaProperties.Add(parameter.Name!, parameterSchema); + if (parameter.TryGetCustomAttribute(out _) || !parameter.ParameterType.IsNullable() || parameter.DefaultValue == DBNull.Value) requiredProperties.Add(parameter.Name!); + } + schemaBuilder.Properties(messageSchemaProperties); + schemaBuilder.Required(requiredProperties); + requestMessagePayloadSchema = schemaBuilder.Build(); + } + else + { + requestMessagePayloadSchema = new JsonSchemaBuilder().FromType(requestMessageType, schemaGeneratorConfiguration).Build(); + } + requestMessageAttribute ??= requestMessageType?.GetCustomAttribute(); + var requestMessageName = $"{operationAttribute.Name}-request"; + var replyMessageName = $"{operationAttribute.Name}-reply"; + document.WithOperation(operationAttribute.Name, operation => + { + operation + .WithAction(operationAttribute.Action) + .WithChannel(operationAttribute.Channel) + .WithTitle(operationAttribute.Title) + .WithSummary(operationAttribute.Summary) + .WithDescription(operationAttribute.Description) + .WithMessage($"#/components/messages/{requestMessageName}"); + if (operationAttribute.ExternalDocumentationUrl != null) + { + operation.WithExternalDocumentation(doc => doc.WithUrl(operationAttribute.ExternalDocumentationUrl)); + } + foreach(var tagAttribute in operationMethod.GetCustomAttributes()) + { + operation.WithTag(tag => tag + .WithName(tagAttribute.Name) + .WithDescription(tagAttribute.Description)); + } + }); + document.WithMessageComponent(requestMessageName, message => + { + message + .WithName(requestMessageAttribute?.Name) + .WithTitle(requestMessageAttribute?.Title) + .WithDescription(requestMessageAttribute?.Description) + .WithSummary(requestMessageAttribute?.Summary) + .WithDescription(requestMessageAttribute?.Description); + if (requestMessagePayloadSchema != null) + { + message + .WithPayloadSchema(schema => schema + .WithFormat("application/schema+json") + .WithSchema(requestMessagePayloadSchema)); + } + if (requestMessageAttribute?.ExternalDocumentationUrl != null) + { + message.WithExternalDocumentation(doc => doc.WithUrl(requestMessageAttribute.ExternalDocumentationUrl)); + } + }); + return Task.CompletedTask; + } + +} diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentProvider.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentProvider.cs index c55b273..e4a01a9 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentProvider.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentProvider.cs @@ -22,8 +22,8 @@ namespace Neuroglia.AsyncApi; /// Represents the default implementation of the interface /// /// The current -/// The options used to configure how to generate code-first s -/// The service used to generate code-first s +/// The options used to configure how to generate code-first s +/// The service used to generate code-first s public class AsyncApiDocumentProvider(IServiceProvider serviceProvider, IOptions generationOptions, IAsyncApiDocumentGenerator generator) : IHostedService, IAsyncApiDocumentProvider { @@ -44,31 +44,42 @@ public class AsyncApiDocumentProvider(IServiceProvider serviceProvider, IOptions protected IAsyncApiDocumentGenerator Generator { get; } = generator; /// - /// Gets a containing all known s + /// Gets a containing all known s /// - protected List? Documents { get; private set; } + protected List? Documents { get; private set; } /// public virtual async Task StartAsync(CancellationToken cancellationToken) { - this.Documents = this.ServiceProvider.GetService>()?.ToList() ?? []; - this.Documents.AddRange((await this.Generator.GenerateAsync(this.GenerationOptions.MarkupTypes, new AsyncApiDocumentGenerationOptions() { DefaultConfiguration = this.GenerationOptions.DefaultDocumentConfiguration }, cancellationToken).ConfigureAwait(false)).ToList()); + var generationOptions = new AsyncApiDocumentGenerationOptions() + { + V2BuilderSetup = this.GenerationOptions.DefaultV2DocumentConfiguration, + V3BuilderSetup = this.GenerationOptions.DefaultV3DocumentConfiguration + }; + this.Documents = this.ServiceProvider.GetService>()?.ToList() ?? []; + this.Documents.AddRange((await this.Generator.GenerateAsync(this.GenerationOptions.MarkupTypes, generationOptions, cancellationToken).ConfigureAwait(false)).ToList()); } /// public virtual Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; /// - public virtual Task GetDocumentAsync(string title, string version, CancellationToken cancellationToken = default) + public virtual Task GetDocumentAsync(string title, string version, CancellationToken cancellationToken = default) { - return Task.FromResult(this.Documents!.FirstOrDefault(d => (d.Info.Title.Equals(title, StringComparison.OrdinalIgnoreCase) || d.Info.Title.ToKebabCase().Equals(title, StringComparison.OrdinalIgnoreCase)) && d.Info.Version.Equals(version, StringComparison.OrdinalIgnoreCase))); + ArgumentException.ThrowIfNullOrWhiteSpace(title); + ArgumentException.ThrowIfNullOrWhiteSpace(version); + return Task.FromResult(this.Documents!.FirstOrDefault(d => (d.Title.Equals(title, StringComparison.OrdinalIgnoreCase) || d.Title.ToKebabCase().Equals(title, StringComparison.OrdinalIgnoreCase)) && d.Version.Equals(version, StringComparison.OrdinalIgnoreCase))); } /// - public virtual Task GetDocumentAsync(string id, CancellationToken cancellationToken = default) => Task.FromResult(this.Documents!.FirstOrDefault(d => !string.IsNullOrWhiteSpace(d.Id) && d.Id.Equals(id, StringComparison.OrdinalIgnoreCase))); + public virtual Task GetDocumentAsync(string id, CancellationToken cancellationToken = default) + { + ArgumentException.ThrowIfNullOrWhiteSpace(id); + return Task.FromResult(this.Documents!.FirstOrDefault(d => !string.IsNullOrWhiteSpace(d.Id) && d.Id.Equals(id, StringComparison.OrdinalIgnoreCase))); + } /// - public virtual IEnumerator GetEnumerator() => this.Documents?.GetEnumerator() ?? new List().GetEnumerator(); + public virtual IEnumerator GetEnumerator() => this.Documents?.GetEnumerator() ?? new List().GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator(); diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptions.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptions.cs index ebae59f..bf84c3e 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptions.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptions.cs @@ -11,10 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.FluentBuilders.v2; -using Neuroglia.AsyncApi.v2; - -namespace Neuroglia.AsyncApi; +namespace Neuroglia.AsyncApi.Generation; /// /// Represents the options used to configure code-first AsyncAPI document generation @@ -30,6 +27,11 @@ public class AsyncApiGenerationOptions /// /// Gets/sets the used to apply a default configuration to generated s /// - public virtual Action? DefaultDocumentConfiguration { get; set; } + public virtual Action? DefaultV2DocumentConfiguration { get; set; } + + /// + /// Gets/sets the used to apply a default configuration to generated s + /// + public virtual Action? DefaultV3DocumentConfiguration { get; set; } } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptionsBuilder.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptionsBuilder.cs index a6ba828..314276b 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptionsBuilder.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiGenerationOptionsBuilder.cs @@ -11,19 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.FluentBuilders.v2; - namespace Neuroglia.AsyncApi.Generation; /// /// Represents the default implementation of the interface /// -/// -/// Initializes a new -/// /// The to configure public class AsyncApiGenerationOptionsBuilder(AsyncApiGenerationOptions options) - : IAsyncApiGenerationOptionsBuilder + : IAsyncApiGenerationOptionsBuilder { /// @@ -40,23 +35,31 @@ public AsyncApiGenerationOptionsBuilder() : this(new()) { } public virtual IAsyncApiGenerationOptionsBuilder WithMarkupType(Type markupType) { ArgumentNullException.ThrowIfNull(markupType); - - this.Options.MarkupTypes.Add(markupType); - + Options.MarkupTypes.Add(markupType); return this; } /// - public virtual IAsyncApiGenerationOptionsBuilder WithMarkupType() => this.WithMarkupType(typeof(TMarkup)); + public virtual IAsyncApiGenerationOptionsBuilder WithMarkupType() => WithMarkupType(typeof(TMarkup)); /// - public virtual IAsyncApiGenerationOptionsBuilder UseDefaultConfiguration(Action configurationAction) + public virtual IAsyncApiGenerationOptionsBuilder UseDefaultV2DocumentConfiguration(Action configurationAction) { - this.Options.DefaultDocumentConfiguration = configurationAction; + ArgumentNullException.ThrowIfNull(configurationAction); + Options.DefaultV2DocumentConfiguration = configurationAction; return this; } /// - public virtual AsyncApiGenerationOptions Build() => this.Options; + public virtual IAsyncApiGenerationOptionsBuilder UseDefaultV3DocumentConfiguration(Action configurationAction) + { + ArgumentNullException.ThrowIfNull(configurationAction); + Options.DefaultV3DocumentConfiguration = configurationAction; + return this; + } + + /// + public virtual AsyncApiGenerationOptions Build() => Options; + } diff --git a/src/Neuroglia.AsyncApi.Generation/DateTimeOffsetJsonSchemaGenerator.cs b/src/Neuroglia.AsyncApi.Generation/DateTimeOffsetJsonSchemaGenerator.cs new file mode 100644 index 0000000..14e097b --- /dev/null +++ b/src/Neuroglia.AsyncApi.Generation/DateTimeOffsetJsonSchemaGenerator.cs @@ -0,0 +1,36 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Json.Schema.Generation.Generators; +using Json.Schema.Generation.Intents; + +namespace Neuroglia.AsyncApi.Generation; + +/// +/// Represents an used to generate s for s +/// +public class DateTimeOffsetJsonSchemaGenerator + : ISchemaGenerator +{ + + /// + public virtual bool Handles(Type type) => type == typeof(DateTimeOffset); + + /// + public virtual void AddConstraints(SchemaGenerationContextBase context) + { + context.Intents.Add(new TypeIntent(SchemaValueType.String)); + context.Intents.Add(new FormatIntent(new("date-time"))); + } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiGenerationOptionsBuilder.cs b/src/Neuroglia.AsyncApi.Generation/IAsyncApiGenerationOptionsBuilder.cs similarity index 76% rename from src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiGenerationOptionsBuilder.cs rename to src/Neuroglia.AsyncApi.Generation/IAsyncApiGenerationOptionsBuilder.cs index 59505ed..7f37686 100644 --- a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiGenerationOptionsBuilder.cs +++ b/src/Neuroglia.AsyncApi.Generation/IAsyncApiGenerationOptionsBuilder.cs @@ -11,9 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.FluentBuilders.v2; -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.Generation; /// @@ -41,7 +38,14 @@ public interface IAsyncApiGenerationOptionsBuilder /// /// The used to configure the used to build s /// The configured - IAsyncApiGenerationOptionsBuilder UseDefaultConfiguration(Action configurationAction); + IAsyncApiGenerationOptionsBuilder UseDefaultV2DocumentConfiguration(Action configurationAction); + + /// + /// Configures the to use the specified to setup the default configuration for generated s + /// + /// The used to configure the used to build s + /// The configured + IAsyncApiGenerationOptionsBuilder UseDefaultV3DocumentConfiguration(Action configurationAction); /// /// Builds new diff --git a/src/Neuroglia.AsyncApi.Generation/Interfaces/IJsonSchemaExampleGenerator.cs b/src/Neuroglia.AsyncApi.Generation/IJsonSchemaExampleGenerator.cs similarity index 100% rename from src/Neuroglia.AsyncApi.Generation/Interfaces/IJsonSchemaExampleGenerator.cs rename to src/Neuroglia.AsyncApi.Generation/IJsonSchemaExampleGenerator.cs diff --git a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentGenerator.cs b/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentGenerator.cs index 647a62c..a9a7c9f 100644 --- a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentGenerator.cs +++ b/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentGenerator.cs @@ -11,23 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v2; - namespace Neuroglia.AsyncApi.Generation; /// -/// Defines the fundamentals of a service used to generate s in a code-first fashion +/// Defines the fundamentals of a service used to generate s in a code-first fashion /// public interface IAsyncApiDocumentGenerator { /// - /// Generates code-first s for types reflected in the specified assemblies + /// Generates code-first s for types reflected in the specified assemblies /// /// An containing the mark up types belonging to the assemblies to scan /// The to use /// A - /// An containing the generated s - Task> GenerateAsync(IEnumerable markupTypes, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default); + /// An containing the generated s + Task> GenerateAsync(IEnumerable markupTypes, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default); } diff --git a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentProvider.cs b/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentProvider.cs index 6830026..1c12059 100644 --- a/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentProvider.cs +++ b/src/Neuroglia.AsyncApi.Generation/Interfaces/IAsyncApiDocumentProvider.cs @@ -14,27 +14,27 @@ namespace Neuroglia.AsyncApi.Generation; /// -/// Defines the fundamentals of a service used to manage s +/// Defines the fundamentals of a service used to manage s /// public interface IAsyncApiDocumentProvider - : IEnumerable + : IEnumerable { /// - /// Gets the with the specified title and version + /// Gets the with the specified title and version /// - /// The title of the to get - /// The version of the to get + /// The title of the to get + /// The version of the to get /// A - /// The with the specified title and version, if any - Task GetDocumentAsync(string title, string version, CancellationToken cancellationToken = default); + /// The with the specified title and version, if any + Task GetDocumentAsync(string title, string version, CancellationToken cancellationToken = default); /// - /// Gets the with the specified id + /// Gets the with the specified id /// - /// The id of the to get + /// The id of the to get /// A - /// The with the specified id, if any - Task GetDocumentAsync(string id, CancellationToken cancellationToken = default); + /// The with the specified id, if any + Task GetDocumentAsync(string id, CancellationToken cancellationToken = default); } diff --git a/src/Neuroglia.AsyncApi.Generation/JsonSchemaExampleGenerator.cs b/src/Neuroglia.AsyncApi.Generation/JsonSchemaExampleGenerator.cs index 1d16d18..27a8b0f 100644 --- a/src/Neuroglia.AsyncApi.Generation/JsonSchemaExampleGenerator.cs +++ b/src/Neuroglia.AsyncApi.Generation/JsonSchemaExampleGenerator.cs @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia; using Neuroglia.Serialization; using System.Collections; using System.Text.Json.Nodes; @@ -42,7 +43,7 @@ protected JsonSchema DefaultSchema { get { - if (this._defaultSchema == null) + if (_defaultSchema == null) { var schemaBuilder = new JsonSchemaBuilder(); var schemaProperties = new Dictionary @@ -52,9 +53,9 @@ protected JsonSchema DefaultSchema { "property3", schemaBuilder.FromType() }, }; schemaBuilder.Properties(schemaProperties); - this._defaultSchema = schemaBuilder.Build(); + _defaultSchema = schemaBuilder.Build(); } - return this._defaultSchema; + return _defaultSchema; } } @@ -102,7 +103,7 @@ protected JsonSchema DefaultSchema if (maxItems.HasValue && maxItems < 5) itemsCount = (int)maxItems.Value; var array = new List(itemsCount); - var itemSchema = schema.GetItems() ?? this.DefaultSchema; + var itemSchema = schema.GetItems() ?? DefaultSchema; for (var i = 0; i < itemsCount; i++) array.Add(GenerateExample(itemSchema, string.Empty, requiredPropertiesOnly)!); return array; @@ -153,7 +154,7 @@ protected JsonSchema DefaultSchema var example = new JsonObject(); var objectSchema = schema; - if (objectSchema.GetProperties()?.Any() != true) schema = this.DefaultSchema; + if (objectSchema.GetProperties()?.Any() != true) schema = DefaultSchema; var requiredProperties = objectSchema.GetRequired(); var properties = objectSchema.GetProperties()?.Where(p => !requiredPropertiesOnly || requiredProperties?.Contains(p.Key) == true); @@ -162,22 +163,22 @@ protected JsonSchema DefaultSchema if (requiredPropertiesOnly) return example; - var propertyValue = this.GenerateExample(new JsonSchemaBuilder().FromType()); - example.Add("property1", JsonNode.Parse(this.Serializer.SerializeToText(propertyValue))); + var propertyValue = GenerateExample(new JsonSchemaBuilder().FromType()); + example.Add("property1", JsonNode.Parse(Serializer.SerializeToText(propertyValue))); - propertyValue = this.GenerateExample(new JsonSchemaBuilder().FromType()); - example.Add("property2", JsonNode.Parse(this.Serializer.SerializeToText(propertyValue))); + propertyValue = GenerateExample(new JsonSchemaBuilder().FromType()); + example.Add("property2", JsonNode.Parse(Serializer.SerializeToText(propertyValue))); - propertyValue = this.GenerateExample(new JsonSchemaBuilder().FromType()); - example.Add("property3", JsonNode.Parse(this.Serializer.SerializeToText(propertyValue))); + propertyValue = GenerateExample(new JsonSchemaBuilder().FromType()); + example.Add("property3", JsonNode.Parse(Serializer.SerializeToText(propertyValue))); } else { foreach (var property in properties) { - var propertyValue = this.GenerateExample(property.Value, property.Key, requiredPropertiesOnly); - example.Add(property.Key, JsonNode.Parse(this.Serializer.SerializeToText(propertyValue))); + var propertyValue = GenerateExample(property.Value, property.Key, requiredPropertiesOnly); + example.Add(property.Key, JsonNode.Parse(Serializer.SerializeToText(propertyValue))); } } diff --git a/src/Neuroglia.AsyncApi.Generation/Neuroglia.AsyncApi.Generation.csproj b/src/Neuroglia.AsyncApi.Generation/Neuroglia.AsyncApi.Generation.csproj index 3501ba7..b79ad43 100644 --- a/src/Neuroglia.AsyncApi.Generation/Neuroglia.AsyncApi.Generation.csproj +++ b/src/Neuroglia.AsyncApi.Generation/Neuroglia.AsyncApi.Generation.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable True diff --git a/src/Neuroglia.AsyncApi.Generation/Usings.cs b/src/Neuroglia.AsyncApi.Generation/Usings.cs index 526dc38..7df3f99 100644 --- a/src/Neuroglia.AsyncApi.Generation/Usings.cs +++ b/src/Neuroglia.AsyncApi.Generation/Usings.cs @@ -14,6 +14,8 @@ global using Json.Schema; global using Json.Schema.Generation; global using Microsoft.Extensions.DependencyInjection; -global using Neuroglia.AsyncApi.FluentBuilders; +global using Neuroglia.AsyncApi.FluentBuilders.v2; +global using Neuroglia.AsyncApi.FluentBuilders.v3; global using Neuroglia.AsyncApi.v2; +global using Neuroglia.AsyncApi.v3; global using System.Reflection; diff --git a/src/Neuroglia.AsyncApi.Generation/XmlDocumentationJsonSchemaRefiner.cs b/src/Neuroglia.AsyncApi.Generation/XmlDocumentationJsonSchemaRefiner.cs new file mode 100644 index 0000000..262d9b4 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Generation/XmlDocumentationJsonSchemaRefiner.cs @@ -0,0 +1,55 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Json.Schema.Generation.Intents; + +namespace Neuroglia.AsyncApi.Generation; + +/// +/// Represents an implementation used to refine schemas by adding xml-based descriptions +/// +public class XmlDocumentationJsonSchemaRefiner + : ISchemaRefiner +{ + + /// + public virtual bool ShouldRun(SchemaGenerationContextBase context) => context.Intents.OfType().Any(); + + /// + public virtual void Run(SchemaGenerationContextBase context) + { + var propertiesIntent = context.Intents.OfType().First(); + foreach (var (propertyName, propertyContext) in propertiesIntent.Properties) + { + var property = context.Type.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase); + if (property == null) continue; + try + { + var description = XmlDocumentationHelper.SummaryOf(property); + if (string.IsNullOrEmpty(description)) continue; + var clonedContext = CloneSchemaContext(propertyContext); + clonedContext.Intents.Add(new DescriptionIntent(description)); + propertiesIntent.Properties[propertyName] = clonedContext; + } + catch { } + } + } + + SchemaGenerationContextBase CloneSchemaContext(SchemaGenerationContextBase originalContext) + { + var clonedContext = (TypeGenerationContext)Activator.CreateInstance(typeof(TypeGenerationContext), BindingFlags.Default | BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly, null, [originalContext.Type], null)!; + foreach (var intent in originalContext.Intents) clonedContext.Intents.Add(intent); + return clonedContext; + } + +} diff --git a/src/Neuroglia.AsyncApi.IO/Neuroglia.AsyncApi.IO.csproj b/src/Neuroglia.AsyncApi.IO/Neuroglia.AsyncApi.IO.csproj index 5b9426a..73cec73 100644 --- a/src/Neuroglia.AsyncApi.IO/Neuroglia.AsyncApi.IO.csproj +++ b/src/Neuroglia.AsyncApi.IO/Neuroglia.AsyncApi.IO.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable True diff --git a/src/Neuroglia.AsyncApi.Validation/Neuroglia.AsyncApi.Validation.csproj b/src/Neuroglia.AsyncApi.Validation/Neuroglia.AsyncApi.Validation.csproj index b34aade..3449afe 100644 --- a/src/Neuroglia.AsyncApi.Validation/Neuroglia.AsyncApi.Validation.csproj +++ b/src/Neuroglia.AsyncApi.Validation/Neuroglia.AsyncApi.Validation.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable True diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Generation/JsonSchemaExampleGeneratorTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Generation/JsonSchemaExampleGeneratorTests.cs index be7ebcd..743b6a3 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Generation/JsonSchemaExampleGeneratorTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Generation/JsonSchemaExampleGeneratorTests.cs @@ -11,6 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.Generation.v2.Interfaces; + namespace Neuroglia.AsyncApi.UnitTests.Cases.Generation; public class JsonSchemaExampleGeneratorTests diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Neuroglia.AsyncApi.UnitTests.csproj b/tests/Neuroglia.AsyncApi.UnitTests/Neuroglia.AsyncApi.UnitTests.csproj index 6f689b2..b598556 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Neuroglia.AsyncApi.UnitTests.csproj +++ b/tests/Neuroglia.AsyncApi.UnitTests/Neuroglia.AsyncApi.UnitTests.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable From 0d8c598fc6c188614cc8fc91fb3e17bd65b777c3 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Thu, 19 Dec 2024 11:06:53 +0100 Subject: [PATCH 08/21] feat(Core): Added extensions used to dereference V3 components Signed-off-by: Charles d'Avernas --- .../CorrelationIdDefinitionViewModel.cs | 8 +- .../v2/Attributes/TagV2Attribute.cs | 8 +- .../v2/V2AsyncApiDocument.cs | 4 +- .../v2/V2ComponentDefinitionCollection.cs | 4 +- .../V2CorrelationIdDefinition.cs} | 4 +- .../v2/V2ExternalDocumentationDefinition.cs | 39 ++ .../v2/V2MessageTraitDefinition.cs | 6 +- .../v2/V2OperationTraitDefinition.cs | 4 +- .../v2/V2ServerDefinition.cs | 2 +- .../V2ServerVariableDefinition.cs} | 4 +- .../v2/V2TagDefinition.cs | 45 ++ .../v3/Attributes/TagV3Attribute.cs | 8 +- .../V3AsyncApiDocumentExtensions.cs | 357 +++++++++++++++ src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs | 4 +- .../v3/V3ChannelDefinition.cs | 4 +- .../v3/V3ComponentDefinitionCollection.cs | 8 +- .../v3/V3CorrelationIdDefinition.cs | 52 +++ .../V3ExternalDocumentationDefinition.cs} | 4 +- .../v3/V3MessageTraitDefinition.cs | 6 +- .../v3/V3OperationTraitDefinition.cs | 4 +- .../v3/V3ServerDefinition.cs | 6 +- .../v3/V3ServerVariableDefinition.cs | 48 ++ .../V3TagDefinition.cs} | 6 +- ...IExternalDocumentationDefinitionBuilder.cs | 43 -- .../IServerVariableDefinitionBuilder.cs | 56 --- .../Interfaces/IV2AsyncApiDocumentBuilder.cs | 10 +- .../IV2CorrelationIdDefinitionBuilder.cs} | 26 +- ...2ExternalDocumentationDefinitionBuilder.cs | 42 ++ .../IV2MessageTraitDefinitionBuilder.cs | 2 +- .../IV2OperationTraitDefinitionBuilder.cs | 2 +- .../Interfaces/IV2ServerDefinitionBuilder.cs | 8 +- .../IV2ServerVariableDefinitionBuilder.cs | 56 +++ .../Interfaces/IV2TagDefinitionBuilder.cs} | 31 +- .../v2/V2AsyncApiDocumentBuilder.cs | 6 +- .../V2CorrelationIdDefinitionBuilder.cs} | 24 +- ...2ExternalDocumentationDefinitionBuilder.cs | 63 +++ .../v2/V2MessageTraitDefinitionBuilder.cs | 6 +- .../v2/V2OperationTraitDefinitionBuilder.cs | 6 +- .../v2/V2SecuritySchemeDefinitionBuilder.cs | 2 +- .../v2/V2ServerDefinitionBuilder.cs | 6 +- .../V2ServerVariableDefinitionBuilder.cs} | 32 +- .../v2/V2TagDefinitionBuilder.cs | 68 +++ .../Interfaces/IV3AsyncApiDocumentBuilder.cs | 34 +- .../Interfaces/IV3ChannelDefinitionBuilder.cs | 4 +- .../IV3CorrelationIdDefinitionBuilder.cs | 43 ++ ...3ExternalDocumentationDefinitionBuilder.cs | 43 ++ .../IV3MessageTraitDefinitionBuilder.cs | 8 +- .../IV3OperationDefinitionBuilder.cs | 6 - .../IV3OperationTraitDefinitionBuilder.cs | 8 +- .../Interfaces/IV3ServerDefinitionBuilder.cs | 12 +- .../IV3ServerVariableDefinitionBuilder.cs | 57 +++ .../v3/Interfaces/IV3TagDefinitionBuilder.cs | 51 +++ ...ExternalDocumentationDefinitionBuilder.cs} | 24 +- .../v3/V3AsyncApiDocumentBuilder.cs | 430 ++++++++++++++++++ .../v3/V3ChannelDefinitionBuilder.cs | 428 +---------------- .../v3/V3CorrelationIdDefinitionBuilder.cs | 70 +++ .../v3/V3MessageTraitDefinitionBuilder.cs | 12 +- .../v3/V3OperationTraitDefinitionBuilder.cs | 8 +- .../v3/V3SecuritySchemeDefinitionBuilder.cs | 2 +- .../v3/V3ServerDefinitionBuilder.cs | 12 +- .../v3/V3ServerVariableDefinitionBuilder.cs | 74 +++ .../V3TagDefinitionBuilder.cs} | 28 +- .../v2/TagValidator.cs | 4 +- .../JsonSchemaExampleGeneratorTests.cs | 2 - .../Services/AsyncApiDocumentFactory.cs | 4 +- 65 files changed, 1748 insertions(+), 740 deletions(-) rename src/Neuroglia.AsyncApi.Core/{CorrelationIdDefinition.cs => v2/V2CorrelationIdDefinition.cs} (96%) create mode 100644 src/Neuroglia.AsyncApi.Core/v2/V2ExternalDocumentationDefinition.cs rename src/Neuroglia.AsyncApi.Core/{ServerVariableDefinition.cs => v2/V2ServerVariableDefinition.cs} (96%) create mode 100644 src/Neuroglia.AsyncApi.Core/v2/V2TagDefinition.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/Extensions/V3AsyncApiDocumentExtensions.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3CorrelationIdDefinition.cs rename src/Neuroglia.AsyncApi.Core/{ExternalDocumentationDefinition.cs => v3/V3ExternalDocumentationDefinition.cs} (95%) create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3ServerVariableDefinition.cs rename src/Neuroglia.AsyncApi.Core/{TagDefinition.cs => v3/V3TagDefinition.cs} (92%) delete mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IExternalDocumentationDefinitionBuilder.cs delete mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerVariableDefinitionBuilder.cs rename src/Neuroglia.AsyncApi.FluentBuilders/{Interfaces/ICorrelationIdDefinitionBuilder.cs => v2/Interfaces/IV2CorrelationIdDefinitionBuilder.cs} (51%) create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ExternalDocumentationDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ServerVariableDefinitionBuilder.cs rename src/Neuroglia.AsyncApi.FluentBuilders/{Interfaces/ITagDefinitionBuilder.cs => v2/Interfaces/IV2TagDefinitionBuilder.cs} (56%) rename src/Neuroglia.AsyncApi.FluentBuilders/{CorrelationIdDefinitionBuilder.cs => v2/V2CorrelationIdDefinitionBuilder.cs} (66%) create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ExternalDocumentationDefinitionBuilder.cs rename src/Neuroglia.AsyncApi.FluentBuilders/{ServerVariableDefinitionBuilder.cs => v2/V2ServerVariableDefinitionBuilder.cs} (53%) create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v2/V2TagDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3CorrelationIdDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ExternalDocumentationDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerVariableDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3TagDefinitionBuilder.cs rename src/Neuroglia.AsyncApi.FluentBuilders/{ExternalDocumentationDefinitionBuilder.cs => v3/V2ExternalDocumentationDefinitionBuilder.cs} (64%) create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3AsyncApiDocumentBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3CorrelationIdDefinitionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerVariableDefinitionBuilder.cs rename src/Neuroglia.AsyncApi.FluentBuilders/{TagDefinitionBuilder.cs => v3/V3TagDefinitionBuilder.cs} (63%) diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs index 51df652..bfe53e9 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs @@ -16,19 +16,19 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; /// -/// Holds the data used to render an view +/// Holds the data used to render an view /// public record CorrelationIdDefinitionViewModel : V2AsyncApiDocumentViewModel { /// - public CorrelationIdDefinitionViewModel(V2AsyncApiDocument document, CorrelationIdDefinition correlationId) : base(document) { this.CorrelationId = correlationId; } + public CorrelationIdDefinitionViewModel(V2AsyncApiDocument document, V2CorrelationIdDefinition correlationId) : base(document) { this.CorrelationId = correlationId; } /// - /// Gets the to render + /// Gets the to render /// - public CorrelationIdDefinition CorrelationId { get; } + public V2CorrelationIdDefinition CorrelationId { get; } } diff --git a/src/Neuroglia.AsyncApi.Core/v2/Attributes/TagV2Attribute.cs b/src/Neuroglia.AsyncApi.Core/v2/Attributes/TagV2Attribute.cs index 613f037..dafaaae 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/Attributes/TagV2Attribute.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/Attributes/TagV2Attribute.cs @@ -16,20 +16,20 @@ namespace Neuroglia.AsyncApi.v2; /// /// Represents an used to tag an Async API component /// -/// The name of the to generate -/// The description of the to generate +/// The name of the to generate +/// The description of the to generate [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] public class TagV2Attribute(string name, string? description = null) : Attribute { /// - /// Gets the name of the to generate + /// Gets the name of the to generate /// public virtual string Name { get; } = name; /// - /// Gets the description of the to generate + /// Gets the description of the to generate /// public virtual string? Description { get; set; } = description; diff --git a/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs b/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs index d4c9cb6..3cf7a6a 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2AsyncApiDocument.cs @@ -75,13 +75,13 @@ public record V2AsyncApiDocument /// Gets/sets a of tags used by the specification with additional metadata. Each tag name in the list MUST be unique. /// [DataMember(Order = 8, Name = "tags"), JsonPropertyOrder(8), JsonPropertyName("tags"), YamlMember(Order = 8, Alias = "tags")] - public virtual EquatableList? Tags { get; set; } + public virtual EquatableList? Tags { get; set; } /// /// Gets/sets an object containing additional external documentation. /// [DataMember(Order = 9, Name = "externalDocs"), JsonPropertyOrder(9), JsonPropertyName("externalDocs"), YamlMember(Order = 9, Alias = "externalDocs")] - public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + public virtual V2ExternalDocumentationDefinition? ExternalDocs { get; set; } /// /// Attempts to get the with the specified id diff --git a/src/Neuroglia.AsyncApi.Core/v2/V2ComponentDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/v2/V2ComponentDefinitionCollection.cs index 3b2aa6c..025ff42 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/V2ComponentDefinitionCollection.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2ComponentDefinitionCollection.cs @@ -46,10 +46,10 @@ public record V2ComponentDefinitionCollection public virtual EquatableDictionary? Parameters { get; set; } /// - /// Gets/sets a used to hold reusable s + /// Gets/sets a used to hold reusable s /// [DataMember(Order = 5, Name = "correlationIds"), JsonPropertyOrder(5), JsonPropertyName("correlationIds"), YamlMember(Order = 5, Alias = "correlationIds")] - public virtual EquatableDictionary? CorrelationIds { get; set; } + public virtual EquatableDictionary? CorrelationIds { get; set; } /// /// Gets/sets a used to hold reusable s diff --git a/src/Neuroglia.AsyncApi.Core/CorrelationIdDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2CorrelationIdDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/CorrelationIdDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2CorrelationIdDefinition.cs index a3bbd48..e929673 100644 --- a/src/Neuroglia.AsyncApi.Core/CorrelationIdDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2CorrelationIdDefinition.cs @@ -11,13 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi; +namespace Neuroglia.AsyncApi.v2; /// /// Represents an object used to define an Async API correlation ID /// [DataContract] -public record CorrelationIdDefinition +public record V2CorrelationIdDefinition : ReferenceableComponentDefinition { diff --git a/src/Neuroglia.AsyncApi.Core/v2/V2ExternalDocumentationDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2ExternalDocumentationDefinition.cs new file mode 100644 index 0000000..cefc59e --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v2/V2ExternalDocumentationDefinition.cs @@ -0,0 +1,39 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v2; + +/// +/// Represents an object used to define a reference to an external documentation +/// +[DataContract] +public record V2ExternalDocumentationDefinition +{ + + /// + /// Gets/sets the for the target documentation. + /// + [Required] + [DataMember(Order = 1, Name = "url"), JsonPropertyOrder(1), JsonPropertyName("url"), YamlMember(Order = 1, Alias = "url")] + public virtual Uri Url { get; set; } = null!; + + /// + /// Gets/sets an optional description of this documentation. CommonMark syntax can be used for rich text representation. + /// + [DataMember(Order = 2, Name = "description"), JsonPropertyOrder(2), JsonPropertyName("description"), YamlMember(Order = 2, Alias = "description")] + public virtual string? Description { get; set; } + + /// + public override string ToString() => Url.ToString(); + +} diff --git a/src/Neuroglia.AsyncApi.Core/v2/V2MessageTraitDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2MessageTraitDefinition.cs index c91391c..6e94418 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/V2MessageTraitDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2MessageTraitDefinition.cs @@ -40,7 +40,7 @@ public record V2MessageTraitDefinition /// Gets/sets the definition of the correlation ID used for message tracing or matching. /// [DataMember(Order = 3, Name = "correlationId"), JsonPropertyOrder(3), JsonPropertyName("correlationId"), YamlMember(Order = 3, Alias = "correlationId")] - public virtual CorrelationIdDefinition? CorrelationId { get; set; } + public virtual V2CorrelationIdDefinition? CorrelationId { get; set; } /// /// Gets/sets a string containing the name of the schema format used to define the message payload. @@ -84,13 +84,13 @@ public record V2MessageTraitDefinition /// gets/sets a of tags for API documentation control. Tags can be used for logical grouping of operations. /// [DataMember(Order = 10, Name = "tags"), JsonPropertyOrder(10), JsonPropertyName("tags"), YamlMember(Order = 10, Alias = "tags")] - public virtual EquatableList? Tags { get; set; } + public virtual EquatableList? Tags { get; set; } /// /// Gets/sets an object containing additional external documentation for this message. /// [DataMember(Order = 11, Name = "externalDocs"), JsonPropertyOrder(11), JsonPropertyName("externalDocs"), YamlMember(Order = 11, Alias = "externalDocs")] - public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + public virtual V2ExternalDocumentationDefinition? ExternalDocs { get; set; } /// /// Gets/sets an object used to configure the 's s diff --git a/src/Neuroglia.AsyncApi.Core/v2/V2OperationTraitDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2OperationTraitDefinition.cs index 5c3a4b1..2890f04 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/V2OperationTraitDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2OperationTraitDefinition.cs @@ -43,13 +43,13 @@ public record V2OperationTraitDefinition /// Gets/sets a of tags for API documentation control. Tags can be used for logical grouping of operations. /// [DataMember(Order = 4, Name = "tags"), JsonPropertyOrder(4), JsonPropertyName("tags"), YamlMember(Order = 4, Alias = "tags")] - public virtual EquatableList? Tags { get; set; } + public virtual EquatableList? Tags { get; set; } /// /// Gets/sets an object containing additional external documentation for this operation. /// [DataMember(Order = 5, Name = "externalDocs"), JsonPropertyOrder(5), JsonPropertyName("externalDocs"), YamlMember(Order = 5, Alias = "externalDocs")] - public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + public virtual V2ExternalDocumentationDefinition? ExternalDocs { get; set; } /// /// Gets/sets an object used to configure the 's s diff --git a/src/Neuroglia.AsyncApi.Core/v2/V2ServerDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2ServerDefinition.cs index fb0d32b..9f808dc 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/V2ServerDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2ServerDefinition.cs @@ -56,7 +56,7 @@ public record V2ServerDefinition /// Gets/sets an optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text representation. /// [DataMember(Order = 5, Name = "variables"), JsonPropertyOrder(5), JsonPropertyName("variables"), YamlMember(Order = 5, Alias = "variables")] - public virtual EquatableDictionary? Variables { get; set; } + public virtual EquatableDictionary? Variables { get; set; } /// /// Gets/sets an of values that represent alternative security requirement objects that can be used. diff --git a/src/Neuroglia.AsyncApi.Core/ServerVariableDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2ServerVariableDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/ServerVariableDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2ServerVariableDefinition.cs index c88caa0..8b92e4f 100644 --- a/src/Neuroglia.AsyncApi.Core/ServerVariableDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2ServerVariableDefinition.cs @@ -11,13 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi; +namespace Neuroglia.AsyncApi.v2; /// /// Represents an object used to describe a Server Variable for server URL template substitution. /// [DataContract] -public record ServerVariableDefinition +public record V2ServerVariableDefinition : ReferenceableComponentDefinition { diff --git a/src/Neuroglia.AsyncApi.Core/v2/V2TagDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2TagDefinition.cs new file mode 100644 index 0000000..d9fa828 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v2/V2TagDefinition.cs @@ -0,0 +1,45 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v2; + +/// +/// Represents an object used to define a tag assigned to an Async API component +/// +[DataContract] +public record V2TagDefinition +{ + + /// + /// Gets/sets the name of the tag. + /// + [Required] + [DataMember(Order = 1, Name = "name"), JsonPropertyOrder(1), JsonPropertyName("name"), YamlMember(Order = 1, Alias = "name")] + public virtual string Name { get; set; } = null!; + + /// + /// Gets/sets an optional description of this channel item. CommonMark syntax can be used for rich text representation. + /// + [DataMember(Order = 2, Name = "description"), JsonPropertyOrder(2), JsonPropertyName("description"), YamlMember(Order = 2, Alias = "description")] + public virtual string? Description { get; set; } + + /// + /// Gets/sets an object containing additional external documentation for this tag. + /// + [DataMember(Order = 3, Name = "externalDocs"), JsonPropertyOrder(3), JsonPropertyName("externalDocs"), YamlMember(Order = 3, Alias = "externalDocs")] + public virtual V2ExternalDocumentationDefinition? ExternalDocs { get; set; } + + /// + public override string ToString() => Name; + +} diff --git a/src/Neuroglia.AsyncApi.Core/v3/Attributes/TagV3Attribute.cs b/src/Neuroglia.AsyncApi.Core/v3/Attributes/TagV3Attribute.cs index fd85d91..ffd4cd4 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/Attributes/TagV3Attribute.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/Attributes/TagV3Attribute.cs @@ -22,17 +22,17 @@ public class TagV3Attribute { /// - /// Gets a reference to the to use + /// Gets a reference to the to use /// public virtual string? Reference { get; init; } /// - /// Gets the name of the to generate + /// Gets the name of the to generate /// - public virtual string? Name { get; init; } + public virtual string? Name { get; init; } /// - /// Gets the description of the to generate + /// Gets the description of the to generate /// public virtual string? Description { get; init; } diff --git a/src/Neuroglia.AsyncApi.Core/v3/Extensions/V3AsyncApiDocumentExtensions.cs b/src/Neuroglia.AsyncApi.Core/v3/Extensions/V3AsyncApiDocumentExtensions.cs new file mode 100644 index 0000000..238d523 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/Extensions/V3AsyncApiDocumentExtensions.cs @@ -0,0 +1,357 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Defines extensions for s +/// +public static class V3AsyncApiDocumentExtensions +{ + + /// + /// Dereferences the specified component + /// + /// The extended + /// The reference to the component to get + /// The specified component + public static ReferenceableComponentDefinition Dereference(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + var componentType = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[^1]; + return componentType switch + { + "servers" => document.DereferenceServer(reference), + "channels" => document.DereferenceChannel(reference), + "operations" => document.DereferenceOperation(reference), + "schemas" => document.DereferenceSchema(reference), + "messages" => document.DereferenceMessage(reference), + "securitySchemes" => document.DereferenceSecurityScheme(reference), + "serverVariables" => document.DereferenceServerVariable(reference), + "parameters" => document.DereferenceParameter(reference), + "correlationIds" => document.DereferenceCorrelationId(reference), + "replies" => document.DereferenceReply(reference), + "replyAddresses" => document.DereferenceReplyAddress(reference), + "externalDocs" => document.DereferenceExternalDoc(reference), + "tags" => document.DereferenceTag(reference), + "operationTraits" => document.DereferenceOperationTrait(reference), + "messageTraits" => document.DereferenceMessageTrait(reference), + "serverBindings" => document.DereferenceServerBinding(reference), + "channelBindings" => document.DereferenceChannelBinding(reference), + "operationBindings" => document.DereferenceOperationBinding(reference), + "messageBindings" => document.DereferenceMessageBinding(reference), + _ => throw new NotSupportedException($"The specified component type '{componentType}' is not supported") + }; + } + + /// + /// Dereferences the specified component + /// + /// The type of component to dereference + /// The extended + /// The reference to the component to get + /// The specified component + public static TComponent Dereference(this V3AsyncApiDocument document, string reference) + where TComponent : ReferenceableComponentDefinition + { + return (TComponent)document.Dereference(reference); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3ServerDefinition DereferenceServer(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + var referenceComponents = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[1..]; + var componentContainer = referenceComponents[0]; + var componentName = referenceComponents.Last(); + var server = componentContainer switch + { + "servers" => document.Servers?[componentName], + "components" => document.Components?.Servers?[componentName], + _ => throw new NullReferenceException($"Failed to dereference the specified server '{reference}'. The reference is invalid and/or the server is undefined") + } ?? throw new NullReferenceException($"Failed to dereference the specified server '{reference}': it does not exist or cannot be found"); + return server; + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3ChannelDefinition DereferenceChannel(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + var referenceComponents = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[1..]; + var componentContainer = referenceComponents[0]; + var componentName = referenceComponents.Last(); + var channel = componentContainer switch + { + "channels" => document.Channels?[componentName], + "components" => document.Components?.Channels?[componentName], + _ => throw new NullReferenceException($"Failed to dereference the specified channel '{reference}'. The reference is invalid and/or the channel is undefined") + } ?? throw new NullReferenceException($"Failed to dereference the specified channel '{reference}': it does not exist or cannot be found"); + return channel; + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3OperationDefinition DereferenceOperation(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + var referenceComponents = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[1..]; + var componentContainer = referenceComponents[0]; + var componentName = referenceComponents.Last(); + var channel = componentContainer switch + { + "operations" => document.Operations?[componentName], + "components" => document.Components?.Operations?[componentName], + _ => throw new NullReferenceException($"Failed to dereference the specified operation '{reference}'. The reference is invalid and/or the operation is undefined") + } ?? throw new NullReferenceException($"Failed to dereference the specified operation '{reference}': it does not exist or cannot be found"); + return channel; + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3SchemaDefinition DereferenceSchema(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/schemas/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid schema reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.Schemas?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified schema '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3MessageDefinition DereferenceMessage(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/messages/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid message reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.Messages?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified message '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3SecuritySchemeDefinition DereferenceSecurityScheme(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/securitySchemes/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid security scheme reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.SecuritySchemes?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified security scheme '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3ServerVariableDefinition DereferenceServerVariable(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/serverVariables/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid server variable reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.ServerVariables?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified server variable '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3ParameterDefinition DereferenceParameter(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/parameters/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid parameter reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.Parameters?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified parameter '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3CorrelationIdDefinition DereferenceCorrelationId(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/correlationIds/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid correlation id reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.CorrelationIds?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified correlation id '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3OperationReplyDefinition DereferenceReply(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/replies/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid reply reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.Replies?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified reply '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3OperationReplyAddressDefinition DereferenceReplyAddress(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/replyAddresses/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid reply address reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.ReplyAddresses?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified reply address '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3ExternalDocumentationDefinition DereferenceExternalDoc(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/externalDocs/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid external docs reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.ExternalDocs?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified external docs '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3TagDefinition DereferenceTag(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/tags/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid tag reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.Tags?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified tag '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3OperationTraitDefinition DereferenceOperationTrait(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/operationTraits/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid operation trait reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.OperationTraits?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified operation trait '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static V3MessageTraitDefinition DereferenceMessageTrait(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/messageTraits/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid message trait reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.MessageTraits?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified message trait '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static ServerBindingDefinitionCollection DereferenceServerBinding(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/serverBindings/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid server binding reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.ServerBindings?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified server binding '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static ChannelBindingDefinitionCollection DereferenceChannelBinding(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/channelBindings/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid channel binding reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.ChannelBindings?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified channel binding '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static OperationBindingDefinitionCollection DereferenceOperationBinding(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/operationBindings/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid operation binding reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.OperationBindings?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified operation binding '{reference}': it does not exist or cannot be found"); + } + + /// + /// Dereferences the specified + /// + /// The extended + /// The reference to the to get + /// The specified + public static MessageBindingDefinitionCollection DereferenceMessageBinding(this V3AsyncApiDocument document, string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + if (!reference.StartsWith("#/components/messageBindings/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid message binding reference"); + var componentName = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Last(); + return document.Components?.MessageBindings?[componentName] ?? throw new NullReferenceException($"Failed to dereference the specified message binding '{reference}': it does not exist or cannot be found"); + } + +} diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs index 412090f..2c6cc73 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs @@ -62,13 +62,13 @@ public record V3ApiInfo /// Gets/sets a list of tags for application API documentation control. Tags can be used for logical grouping of applications. /// [DataMember(Order = 7, Name = "tags"), JsonPropertyOrder(7), JsonPropertyName("tags"), YamlMember(Order = 7, Alias = "tags")] - public virtual EquatableList? Tags { get; set; } + public virtual EquatableList? Tags { get; set; } /// /// Gets/sets additional external documentation of the exposed API. /// [DataMember(Order = 8, Name = "externalDocs"), JsonPropertyOrder(8), JsonPropertyName("externalDocs"), YamlMember(Order = 8, Alias = "externalDocs")] - public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + public virtual V3ExternalDocumentationDefinition? ExternalDocs { get; set; } /// public override string ToString() => this.Title; diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs index 0641cd0..3e8eb17 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs @@ -70,13 +70,13 @@ public record V3ChannelDefinition /// Gets/sets a list of tags for logical grouping of channels. /// [DataMember(Order = 8, Name = "tags"), JsonPropertyOrder(8), JsonPropertyName("tags"), YamlMember(Order = 8, Alias = "tags", ScalarStyle = ScalarStyle.SingleQuoted)] - public virtual EquatableList? Tags { get; set; } + public virtual EquatableList? Tags { get; set; } /// /// Gets/sets additional external documentation for this channel. /// [DataMember(Order = 9, Name = "externalDocs"), JsonPropertyOrder(9), JsonPropertyName("externalDocs"), YamlMember(Order = 9, Alias = "externalDocs", ScalarStyle = ScalarStyle.SingleQuoted)] - public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + public virtual V3ExternalDocumentationDefinition? ExternalDocs { get; set; } /// /// Gets/sets additional external documentation for this channel. diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ComponentDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ComponentDefinitionCollection.cs index 732f8bb..2a09bfe 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3ComponentDefinitionCollection.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ComponentDefinitionCollection.cs @@ -61,7 +61,7 @@ public record V3ComponentDefinitionCollection /// Gets/sets a key/value mapping that contains reusable Server Variable Objects. /// [DataMember(Order = 7, Name = "serverVariables"), JsonPropertyOrder(7), JsonPropertyName("serverVariables"), YamlMember(Order = 7, Alias = "serverVariables")] - public virtual EquatableDictionary? ServerVariables { get; set; } + public virtual EquatableDictionary? ServerVariables { get; set; } /// /// Gets/sets a key/value mapping that contains reusable Parameter Objects. @@ -73,7 +73,7 @@ public record V3ComponentDefinitionCollection /// Gets/sets a key/value mapping that contains reusable Correlation Id Objects. /// [DataMember(Order = 9, Name = "correlationIds"), JsonPropertyOrder(9), JsonPropertyName("correlationIds"), YamlMember(Order = 9, Alias = "correlationIds")] - public virtual EquatableDictionary? CorrelationIds { get; set; } + public virtual EquatableDictionary? CorrelationIds { get; set; } /// /// Gets/sets a key/value mapping that contains reusable Reply Objects. @@ -91,13 +91,13 @@ public record V3ComponentDefinitionCollection /// Gets/sets a key/value mapping that contains reusable External Documentation Objects. /// [DataMember(Order = 12, Name = "externalDocs"), JsonPropertyOrder(12), JsonPropertyName("externalDocs"), YamlMember(Order = 12, Alias = "externalDocs")] - public virtual EquatableDictionary? ExternalDocs { get; set; } + public virtual EquatableDictionary? ExternalDocs { get; set; } /// /// Gets/sets a key/value mapping that contains reusable Tag Objects. /// [DataMember(Order = 13, Name = "tags"), JsonPropertyOrder(13), JsonPropertyName("tags"), YamlMember(Order = 13, Alias = "tags")] - public virtual EquatableDictionary? Tags { get; set; } + public virtual EquatableDictionary? Tags { get; set; } /// /// Gets/sets a key/value mapping that contains reusable Operation Trait Objects. diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3CorrelationIdDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3CorrelationIdDefinition.cs new file mode 100644 index 0000000..fbfa433 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3CorrelationIdDefinition.cs @@ -0,0 +1,52 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object used to define an Async API correlation ID +/// +[DataContract] +public record V3CorrelationIdDefinition + : ReferenceableComponentDefinition +{ + + RuntimeExpression _locationExpression = null!; + + /// + /// Gets/sets a runtime expression that specifies the location of the correlation ID. + /// + [Required] + [DataMember(Order = 1, Name = "location"), JsonPropertyOrder(1), JsonPropertyName("location"), YamlMember(Order = 1, Alias = "location")] + public virtual string Location { get; set; } = null!; + + /// + /// Gets/sets a short description of the application. CommonMark syntax can be used for rich text representation. + /// + [DataMember(Order = 2, Name = "description"), JsonPropertyOrder(2), JsonPropertyName("description"), YamlMember(Order = 2, Alias = "description")] + public virtual string? Description { get; set; } + + /// + /// Gets the location's + /// + [IgnoreDataMember, JsonIgnore, YamlIgnore] + public virtual RuntimeExpression LocationExpression + { + get + { + if (_locationExpression == null && !string.IsNullOrWhiteSpace(Location)) _locationExpression = RuntimeExpression.Parse(Location); + return _locationExpression!; + } + } + +} diff --git a/src/Neuroglia.AsyncApi.Core/ExternalDocumentationDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ExternalDocumentationDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/ExternalDocumentationDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v3/V3ExternalDocumentationDefinition.cs index 99b92c9..886d599 100644 --- a/src/Neuroglia.AsyncApi.Core/ExternalDocumentationDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ExternalDocumentationDefinition.cs @@ -11,13 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi; +namespace Neuroglia.AsyncApi.v3; /// /// Represents an object used to define a reference to an external documentation /// [DataContract] -public record ExternalDocumentationDefinition +public record V3ExternalDocumentationDefinition : ReferenceableComponentDefinition { diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3MessageTraitDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3MessageTraitDefinition.cs index 7b68a8f..a2d573f 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3MessageTraitDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3MessageTraitDefinition.cs @@ -34,7 +34,7 @@ public record V3MessageTraitDefinition /// Gets/sets the definition of the correlation ID used for message tracing or matching. /// [DataMember(Order = 2, Name = "correlationId"), JsonPropertyOrder(2), JsonPropertyName("correlationId"), YamlMember(Order = 2, Alias = "correlationId")] - public virtual CorrelationIdDefinition? CorrelationId { get; set; } + public virtual V3CorrelationIdDefinition? CorrelationId { get; set; } /// /// Gets/sets the content type to use when encoding/decoding a message's payload. @@ -72,13 +72,13 @@ public record V3MessageTraitDefinition /// Gets/sets a list of tags for logical grouping and categorization of messages. /// [DataMember(Order = 8, Name = "tags"), JsonPropertyOrder(8), JsonPropertyName("tags"), YamlMember(Order = 8, Alias = "tags")] - public virtual EquatableList? Tags { get; set; } + public virtual EquatableList? Tags { get; set; } /// /// Gets/sets additional external documentation for this message. /// [DataMember(Order = 9, Name = "externalDocs"), JsonPropertyOrder(9), JsonPropertyName("externalDocs"), YamlMember(Order = 9, Alias = "externalDocs")] - public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + public virtual V3ExternalDocumentationDefinition? ExternalDocs { get; set; } /// /// Gets/sets a map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the message. diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3OperationTraitDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3OperationTraitDefinition.cs index 6afa176..4964b5b 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3OperationTraitDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3OperationTraitDefinition.cs @@ -49,13 +49,13 @@ public record V3OperationTraitDefinition /// Gets/sets a list of tags for logical grouping and categorization of operations. /// [DataMember(Order = 5, Name = "tags"), JsonPropertyOrder(5), JsonPropertyName("tags"), YamlMember(Order = 5, Alias = "tags", ScalarStyle = ScalarStyle.SingleQuoted)] - public virtual EquatableList? Tags { get; set; } + public virtual EquatableList? Tags { get; set; } /// /// Gets/sets additional external documentation for this operation. /// [DataMember(Order = 6, Name = "externalDocs"), JsonPropertyOrder(6), JsonPropertyName("externalDocs"), YamlMember(Order = 6, Alias = "externalDocs", ScalarStyle = ScalarStyle.SingleQuoted)] - public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + public virtual V3ExternalDocumentationDefinition? ExternalDocs { get; set; } /// /// Gets/sets a map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the operation. diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ServerDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ServerDefinition.cs index f8738c1..86aaebd 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3ServerDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ServerDefinition.cs @@ -69,7 +69,7 @@ public record V3ServerDefinition /// Gets/sets a map between a variable name and its value. The value is used for substitution in the server's host and pathname template. /// [DataMember(Order = 8, Name = "variables"), JsonPropertyOrder(8), JsonPropertyName("variables"), YamlMember(Order = 8, Alias = "variables")] - public virtual EquatableDictionary? Variables { get; set; } + public virtual EquatableDictionary? Variables { get; set; } /// /// Gets/sets a declaration of which security schemes can be used with this server. The list of values includes alternative security scheme objects that can be used. Only one of the security scheme objects need to be satisfied to authorize a connection or operation. @@ -81,13 +81,13 @@ public record V3ServerDefinition /// Gets/sets a list of tags for logical grouping and categorization of servers. /// [DataMember(Order = 10, Name = "tags"), JsonPropertyOrder(10), JsonPropertyName("tags"), YamlMember(Order = 10, Alias = "tags")] - public virtual EquatableList? Tags { get; set; } + public virtual EquatableList? Tags { get; set; } /// /// Gets/sets additional external documentation for this server. /// [DataMember(Order = 11, Name = "externalDocs"), JsonPropertyOrder(11), JsonPropertyName("externalDocs"), YamlMember(Order = 11, Alias = "externalDocs")] - public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + public virtual V3ExternalDocumentationDefinition? ExternalDocs { get; set; } /// /// Gets/sets a map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the server. diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ServerVariableDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ServerVariableDefinition.cs new file mode 100644 index 0000000..55d86bd --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ServerVariableDefinition.cs @@ -0,0 +1,48 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object used to describe a Server Variable for server URL template substitution. +/// +[DataContract] +public record V3ServerVariableDefinition + : ReferenceableComponentDefinition +{ + + /// + /// Gets/sets an of values to be used if the substitution options are from a limited set. + /// + [DataMember(Order = 1, Name = "enum"), JsonPropertyOrder(1), JsonPropertyName("enum"), YamlMember(Order = 1, Alias = "enum")] + public virtual EquatableList? Enum { get; set; } + + /// + /// Gets/sets the default value to use for substitution, and to send, if an alternate value is not supplied. + /// + [DataMember(Order = 2, Name = "default"), JsonPropertyOrder(2), JsonPropertyName("default"), YamlMember(Order = 2, Alias = "default")] + public virtual string? Default { get; set; } + + /// + /// Gets/sets an optional string describing the server variable. CommonMark syntax MAY be used for rich text representation. + /// + [DataMember(Order = 3, Name = "description"), JsonPropertyOrder(3), JsonPropertyName("description"), YamlMember(Order = 3, Alias = "description")] + public virtual string? Description { get; set; } + + /// + /// Gets/sets an of examples of the server variable. + /// + [DataMember(Order = 4, Name = "examples"), JsonPropertyOrder(4), JsonPropertyName("examples"), YamlMember(Order = 4, Alias = "examples")] + public virtual EquatableList? Examples { get; set; } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/TagDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3TagDefinition.cs similarity index 92% rename from src/Neuroglia.AsyncApi.Core/TagDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v3/V3TagDefinition.cs index 2462610..99a7f3c 100644 --- a/src/Neuroglia.AsyncApi.Core/TagDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3TagDefinition.cs @@ -11,13 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi; +namespace Neuroglia.AsyncApi.v3; /// /// Represents an object used to define a tag assigned to an Async API component /// [DataContract] -public record TagDefinition +public record V3TagDefinition : ReferenceableComponentDefinition { @@ -38,7 +38,7 @@ public record TagDefinition /// Gets/sets an object containing additional external documentation for this tag. /// [DataMember(Order = 3, Name = "externalDocs"), JsonPropertyOrder(3), JsonPropertyName("externalDocs"), YamlMember(Order = 3, Alias = "externalDocs")] - public virtual ExternalDocumentationDefinition? ExternalDocs { get; set; } + public virtual V3ExternalDocumentationDefinition? ExternalDocs { get; set; } /// public override string ToString() => Name; diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IExternalDocumentationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IExternalDocumentationDefinitionBuilder.cs deleted file mode 100644 index e6e5561..0000000 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IExternalDocumentationDefinitionBuilder.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright © 2021-Present Neuroglia SRL. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"), -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace Neuroglia.AsyncApi.FluentBuilders; - -/// -/// Defines the fundamentals of a service used to build s -/// -public interface IExternalDocumentationDefinitionBuilder - : IReferenceableComponentDefinitionBuilder -{ - - /// - /// Configures the to build to use the specified url - /// - /// The url of the to build - /// The configured - IExternalDocumentationDefinitionBuilder WithUrl(Uri url); - - /// - /// Configures the to build to use the specified description - /// - /// The description of the to build - /// The configured - IExternalDocumentationDefinitionBuilder WithDescription(string? description); - - /// - /// Builds the configured - /// - /// A new - ExternalDocumentationDefinition Build(); - -} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerVariableDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerVariableDefinitionBuilder.cs deleted file mode 100644 index c7a00a0..0000000 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerVariableDefinitionBuilder.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright © 2021-Present Neuroglia SRL. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"), -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace Neuroglia.AsyncApi.FluentBuilders; - -/// -/// Defines the fundamentals of a service used to build s -/// -public interface IServerVariableDefinitionBuilder -{ - - /// - /// Configures the to build to use the specified enum values - /// - /// An array of values to be used if the substitution options are from a limited set. - /// The configured - IServerVariableDefinitionBuilder WithEnumValues(params string[] values); - - /// - /// Configures the to build to use the specified default value - /// - /// The value to use by default for substitution, and to send, if an alternate value is not supplied. - /// The configured - IServerVariableDefinitionBuilder WithDefaultValue(string value); - - /// - /// Configures the to use the specified description - /// - /// The description to use - /// The configured - IServerVariableDefinitionBuilder WithDescription(string? description); - - /// - /// Adds the specified example to the to build - /// - /// The example to add - /// The configured - IServerVariableDefinitionBuilder WithExample(string example); - - /// - /// Builds a new - /// - /// A new - ServerVariableDefinition Build(); - -} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2AsyncApiDocumentBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2AsyncApiDocumentBuilder.cs index a6fdd3f..11ef328 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2AsyncApiDocumentBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2AsyncApiDocumentBuilder.cs @@ -90,7 +90,7 @@ public interface IV2AsyncApiDocumentBuilder /// /// An used to setup the tag to use /// The configured - IV2AsyncApiDocumentBuilder WithTag(Action setup); + IV2AsyncApiDocumentBuilder WithTag(Action setup); /// /// Adds the specified external documentation to the to build @@ -173,12 +173,12 @@ public interface IV2AsyncApiDocumentBuilder IV2AsyncApiDocumentBuilder WithParameterComponent(string name, Action setup); /// - /// Adds the specified + /// Adds the specified /// - /// The name of the to add - /// The to add + /// The name of the to add + /// The to add /// The configured - IV2AsyncApiDocumentBuilder WithCorrelationIdComponent(string name, CorrelationIdDefinition correlationId); + IV2AsyncApiDocumentBuilder WithCorrelationIdComponent(string name, V2CorrelationIdDefinition correlationId); /// /// Adds the specified diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ICorrelationIdDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2CorrelationIdDefinitionBuilder.cs similarity index 51% rename from src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ICorrelationIdDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2CorrelationIdDefinitionBuilder.cs index 4189a67..ab253ac 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ICorrelationIdDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2CorrelationIdDefinitionBuilder.cs @@ -11,33 +11,33 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// -public interface ICorrelationIdDefinitionBuilder - : IReferenceableComponentDefinitionBuilder +public interface IV2CorrelationIdDefinitionBuilder + : IReferenceableComponentDefinitionBuilder { /// - /// Configures the to use the specified location expression + /// Configures the to use the specified location expression /// /// The location expression to use - /// The configured - ICorrelationIdDefinitionBuilder WithLocation(string location); + /// The configured + IV2CorrelationIdDefinitionBuilder WithLocation(string location); /// - /// Configures the to use the specified description + /// Configures the to use the specified description /// /// The description to use - /// The configured - ICorrelationIdDefinitionBuilder WithDescription(string? description); + /// The configured + IV2CorrelationIdDefinitionBuilder WithDescription(string? description); /// - /// Builds the configured + /// Builds the configured /// - /// A new - CorrelationIdDefinition Build(); + /// A new + V2CorrelationIdDefinition Build(); } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ExternalDocumentationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ExternalDocumentationDefinitionBuilder.cs new file mode 100644 index 0000000..6209a95 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ExternalDocumentationDefinitionBuilder.cs @@ -0,0 +1,42 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v2; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV2ExternalDocumentationDefinitionBuilder +{ + + /// + /// Configures the to build to use the specified url + /// + /// The url of the to build + /// The configured + IV2ExternalDocumentationDefinitionBuilder WithUrl(Uri url); + + /// + /// Configures the to build to use the specified description + /// + /// The description of the to build + /// The configured + IV2ExternalDocumentationDefinitionBuilder WithDescription(string? description); + + /// + /// Builds the configured + /// + /// A new + V2ExternalDocumentationDefinition Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2MessageTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2MessageTraitDefinitionBuilder.cs index 561cc45..3ba9765 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2MessageTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2MessageTraitDefinitionBuilder.cs @@ -115,7 +115,7 @@ TBuilder WithHeaders() /// /// An used to setup the tag to use /// The configured - TBuilder WithTag(Action setup); + TBuilder WithTag(Action setup); /// /// Adds the specified example to the to build diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2OperationTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2OperationTraitDefinitionBuilder.cs index 39906bc..e58b03a 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2OperationTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2OperationTraitDefinitionBuilder.cs @@ -49,7 +49,7 @@ public interface IV2OperationTraitDefinitionBuilder /// /// An used to setup the tag to use /// The configured - TBuilder WithTag(Action setup); + TBuilder WithTag(Action setup); /// /// Adds the specified external documentation to the to build diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ServerDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ServerDefinitionBuilder.cs index eb6df73..f21c79b 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ServerDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ServerDefinitionBuilder.cs @@ -42,12 +42,12 @@ public interface IV2ServerDefinitionBuilder IV2ServerDefinitionBuilder WithDescription(string? description); /// - /// Adds the specified to the to build + /// Adds the specified to the to build /// - /// The name of the to add - /// An used to setup the to add + /// The name of the to add + /// An used to setup the to add /// The configured - IV2ServerDefinitionBuilder WithVariable(string name, Action setup); + IV2ServerDefinitionBuilder WithVariable(string name, Action setup); /// /// Configures the to build to use the specified diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ServerVariableDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ServerVariableDefinitionBuilder.cs new file mode 100644 index 0000000..f89080d --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2ServerVariableDefinitionBuilder.cs @@ -0,0 +1,56 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v2; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV2ServerVariableDefinitionBuilder +{ + + /// + /// Configures the to build to use the specified enum values + /// + /// An array of values to be used if the substitution options are from a limited set. + /// The configured + IV2ServerVariableDefinitionBuilder WithEnumValues(params string[] values); + + /// + /// Configures the to build to use the specified default value + /// + /// The value to use by default for substitution, and to send, if an alternate value is not supplied. + /// The configured + IV2ServerVariableDefinitionBuilder WithDefaultValue(string value); + + /// + /// Configures the to use the specified description + /// + /// The description to use + /// The configured + IV2ServerVariableDefinitionBuilder WithDescription(string? description); + + /// + /// Adds the specified example to the to build + /// + /// The example to add + /// The configured + IV2ServerVariableDefinitionBuilder WithExample(string example); + + /// + /// Builds a new + /// + /// A new + V2ServerVariableDefinition Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ITagDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2TagDefinitionBuilder.cs similarity index 56% rename from src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ITagDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2TagDefinitionBuilder.cs index 188e666..26ccc35 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/ITagDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/Interfaces/IV2TagDefinitionBuilder.cs @@ -11,41 +11,40 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// -/// Defines the fundamentals of a service used to build s +/// Defines the fundamentals of a service used to build s /// -public interface ITagDefinitionBuilder - : IReferenceableComponentDefinitionBuilder +public interface IV2TagDefinitionBuilder { /// - /// Configures the to use the specified name + /// Configures the to use the specified name /// /// The name to use - /// The configured - ITagDefinitionBuilder WithName(string name); + /// The configured + IV2TagDefinitionBuilder WithName(string name); /// - /// Configures the to use the specified description + /// Configures the to use the specified description /// /// The description to use - /// The configured - ITagDefinitionBuilder WithDescription(string? description); + /// The configured + IV2TagDefinitionBuilder WithDescription(string? description); /// - /// Adds the specified external documentation to the to build + /// Adds the specified external documentation to the to build /// /// The to the documentation to add /// The description of the documentation to add - /// The configured - ITagDefinitionBuilder WithExternalDocumentation(Uri uri, string? description = null); + /// The configured + IV2TagDefinitionBuilder WithExternalDocumentation(Uri uri, string? description = null); /// - /// Builds a new + /// Builds a new /// - /// A new - TagDefinition Build(); + /// A new + V2TagDefinition Build(); } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2AsyncApiDocumentBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2AsyncApiDocumentBuilder.cs index b36e68a..4b78806 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2AsyncApiDocumentBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2AsyncApiDocumentBuilder.cs @@ -115,11 +115,11 @@ public virtual IV2AsyncApiDocumentBuilder WithDefaultContentType(string contentT } /// - public virtual IV2AsyncApiDocumentBuilder WithTag(Action setup) + public virtual IV2AsyncApiDocumentBuilder WithTag(Action setup) { ArgumentNullException.ThrowIfNull(setup); Document.Tags ??= []; - var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); Document.Tags.Add(builder.Build()); return this; @@ -236,7 +236,7 @@ public virtual IV2AsyncApiDocumentBuilder WithParameterComponent(string name, Ac } /// - public virtual IV2AsyncApiDocumentBuilder WithCorrelationIdComponent(string name, CorrelationIdDefinition correlationId) + public virtual IV2AsyncApiDocumentBuilder WithCorrelationIdComponent(string name, V2CorrelationIdDefinition correlationId) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); ArgumentNullException.ThrowIfNull(correlationId); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/CorrelationIdDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2CorrelationIdDefinitionBuilder.cs similarity index 66% rename from src/Neuroglia.AsyncApi.FluentBuilders/CorrelationIdDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/V2CorrelationIdDefinitionBuilder.cs index 3717911..165d586 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/CorrelationIdDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2CorrelationIdDefinitionBuilder.cs @@ -11,15 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// -/// Represents the default implementation of the interface +/// Represents the default implementation of the interface /// /// The current -/// An containing the services used to validate -public class CorrelationIdDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : ICorrelationIdDefinitionBuilder +/// An containing the services used to validate +public class V2CorrelationIdDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV2CorrelationIdDefinitionBuilder { /// @@ -28,14 +28,14 @@ public class CorrelationIdDefinitionBuilder(IServiceProvider serviceProvider, IE protected IServiceProvider ServiceProvider { get; } = serviceProvider; /// - /// Gets an containing the services used to validate + /// Gets an containing the services used to validate /// - protected IEnumerable> Validators { get; } = validators; + protected IEnumerable> Validators { get; } = validators; /// - /// Gets the to configure + /// Gets the to configure /// - protected CorrelationIdDefinition CorrelationId { get; } = new(); + protected V2CorrelationIdDefinition CorrelationId { get; } = new(); /// public virtual void Use(string reference) @@ -45,7 +45,7 @@ public virtual void Use(string reference) } /// - public virtual ICorrelationIdDefinitionBuilder WithLocation(string location) + public virtual IV2CorrelationIdDefinitionBuilder WithLocation(string location) { ArgumentException.ThrowIfNullOrWhiteSpace(location); CorrelationId.Location = location; @@ -53,14 +53,14 @@ public virtual ICorrelationIdDefinitionBuilder WithLocation(string location) } /// - public virtual ICorrelationIdDefinitionBuilder WithDescription(string? description) + public virtual IV2CorrelationIdDefinitionBuilder WithDescription(string? description) { CorrelationId.Description = description; return this; } /// - public virtual CorrelationIdDefinition Build() + public virtual V2CorrelationIdDefinition Build() { var validationResults = Validators.Select(v => v.Validate(CorrelationId)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ExternalDocumentationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ExternalDocumentationDefinitionBuilder.cs new file mode 100644 index 0000000..ab18300 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ExternalDocumentationDefinitionBuilder.cs @@ -0,0 +1,63 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v2; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// The services used to validate s +public class V2ExternalDocumentationDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV2ExternalDocumentationDefinitionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected virtual V2ExternalDocumentationDefinition ExternalDocumentation { get; } = new(); + + /// + public virtual IV2ExternalDocumentationDefinitionBuilder WithUrl(Uri url) + { + ArgumentNullException.ThrowIfNull(url); + ExternalDocumentation.Url = url; + return this; + } + + /// + public virtual IV2ExternalDocumentationDefinitionBuilder WithDescription(string? description) + { + ExternalDocumentation.Description = description; + return this; + } + + /// + public virtual V2ExternalDocumentationDefinition Build() + { + var validationResults = Validators.Select(v => v.Validate(ExternalDocumentation)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return ExternalDocumentation; + } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2MessageTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2MessageTraitDefinitionBuilder.cs index 78a99c4..a6fccd8 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2MessageTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2MessageTraitDefinitionBuilder.cs @@ -66,16 +66,16 @@ public virtual TBuilder WithExample(string name, object example) public virtual TBuilder WithExternalDocumentation(Uri uri, string? description = null) { ArgumentNullException.ThrowIfNull(uri); - Trait.ExternalDocs = new ExternalDocumentationDefinition() { Url = uri, Description = description }; + Trait.ExternalDocs = new V2ExternalDocumentationDefinition() { Url = uri, Description = description }; return (TBuilder)(object)this; } /// - public virtual TBuilder WithTag(Action setup) + public virtual TBuilder WithTag(Action setup) { ArgumentNullException.ThrowIfNull(setup); Trait.Tags ??= []; - var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); Trait.Tags.Add(builder.Build()); return (TBuilder)(object)this; diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2OperationTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2OperationTraitDefinitionBuilder.cs index fbeab33..c3b5105 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2OperationTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2OperationTraitDefinitionBuilder.cs @@ -54,16 +54,16 @@ protected V2OperationTraitDefinitionBuilder(IServiceProvider serviceProvider, IE public virtual TBuilder WithExternalDocumentation(Uri uri, string? description = null) { ArgumentNullException.ThrowIfNull(uri); - Trait.ExternalDocs = new ExternalDocumentationDefinition() { Url = uri, Description = description }; + Trait.ExternalDocs = new V2ExternalDocumentationDefinition() { Url = uri, Description = description }; return (TBuilder)(object)this; } /// - public virtual TBuilder WithTag(Action setup) + public virtual TBuilder WithTag(Action setup) { ArgumentNullException.ThrowIfNull(setup); Trait.Tags ??= []; - var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); Trait.Tags.Add(builder.Build()); return (TBuilder)(object)this; diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2SecuritySchemeDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2SecuritySchemeDefinitionBuilder.cs index a1a8d6d..db200a4 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2SecuritySchemeDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2SecuritySchemeDefinitionBuilder.cs @@ -99,7 +99,7 @@ public virtual IV2SecuritySchemeDefinitionBuilder WithBearerFormat(string? forma /// public virtual IV2SecuritySchemeDefinitionBuilder WithOAuthFlows(Action setup) { - ArgumentNullException.ThrowIfNull(nameof(setup)); + ArgumentNullException.ThrowIfNull(setup); var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ServerDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ServerDefinitionBuilder.cs index ecbd490..c521de5 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ServerDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ServerDefinitionBuilder.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.FluentBuilders; - namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// @@ -66,10 +64,10 @@ public virtual IV2ServerDefinitionBuilder WithDescription(string? description) } /// - public virtual IV2ServerDefinitionBuilder WithVariable(string name, Action setup) + public virtual IV2ServerDefinitionBuilder WithVariable(string name, Action setup) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); - var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); Server.Variables ??= []; Server.Variables.Add(name, builder.Build()); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/ServerVariableDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ServerVariableDefinitionBuilder.cs similarity index 53% rename from src/Neuroglia.AsyncApi.FluentBuilders/ServerVariableDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ServerVariableDefinitionBuilder.cs index 2357b17..dcc0d2f 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/ServerVariableDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2ServerVariableDefinitionBuilder.cs @@ -11,54 +11,52 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.FluentBuilders; - -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v2; /// -/// Represents the default implementation of the interface +/// Represents the default implementation of the interface /// /// -/// Initializes a new +/// Initializes a new /// -/// The services used to validate s -public class ServerVariableDefinitionBuilder(IEnumerable> validators) - : IServerVariableDefinitionBuilder +/// The services used to validate s +public class V2ServerVariableDefinitionBuilder(IEnumerable> validators) + : IV2ServerVariableDefinitionBuilder { /// - /// Gets the services used to validate s + /// Gets the services used to validate s /// - protected virtual IEnumerable> Validators { get; } = validators; + protected virtual IEnumerable> Validators { get; } = validators; /// - /// Gets the to build + /// Gets the to build /// - protected ServerVariableDefinition Variable { get; } = new(); + protected V2ServerVariableDefinition Variable { get; } = new(); /// - public virtual IServerVariableDefinitionBuilder WithEnumValues(params string[] values) + public virtual IV2ServerVariableDefinitionBuilder WithEnumValues(params string[] values) { Variable.Enum = new(values); return this; } /// - public virtual IServerVariableDefinitionBuilder WithDefaultValue(string value) + public virtual IV2ServerVariableDefinitionBuilder WithDefaultValue(string value) { Variable.Default = value; return this; } /// - public virtual IServerVariableDefinitionBuilder WithDescription(string? description) + public virtual IV2ServerVariableDefinitionBuilder WithDescription(string? description) { Variable.Description = description; return this; } /// - public virtual IServerVariableDefinitionBuilder WithExample(string example) + public virtual IV2ServerVariableDefinitionBuilder WithExample(string example) { if (string.IsNullOrWhiteSpace(example)) throw new ArgumentNullException(nameof(example)); Variable.Examples ??= []; @@ -67,6 +65,6 @@ public virtual IServerVariableDefinitionBuilder WithExample(string example) } /// - public virtual ServerVariableDefinition Build() => Variable; + public virtual V2ServerVariableDefinition Build() => Variable; } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2TagDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2TagDefinitionBuilder.cs new file mode 100644 index 0000000..3b2d7c8 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v2/V2TagDefinitionBuilder.cs @@ -0,0 +1,68 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v2; + +/// +/// Represents the default implementation of the +/// +/// +/// Initializes a new +/// +/// An containing the services used to validate s +public class V2TagDefinitionBuilder(IEnumerable> validators) + : IV2TagDefinitionBuilder +{ + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected virtual V2TagDefinition Tag { get; } = new(); + + /// + public virtual IV2TagDefinitionBuilder WithName(string name) + { + if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); + Tag.Name = name; + return this; + } + + /// + public virtual IV2TagDefinitionBuilder WithDescription(string? description) + { + Tag.Description = description; + return this; + } + + /// + public virtual IV2TagDefinitionBuilder WithExternalDocumentation(Uri uri, string? description = null) + { + ArgumentNullException.ThrowIfNull(uri); + Tag.ExternalDocs = new() { Url = uri, Description = description }; + return this; + } + + /// + public virtual V2TagDefinition Build() + { + var validationResults = Validators.Select(v => v.Validate(Tag)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); + return Tag; + } + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3AsyncApiDocumentBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3AsyncApiDocumentBuilder.cs index 525c462..5fe5631 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3AsyncApiDocumentBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3AsyncApiDocumentBuilder.cs @@ -90,14 +90,14 @@ public interface IV3AsyncApiDocumentBuilder /// /// An used to setup the tag to use /// The configured - IV3AsyncApiDocumentBuilder WithTag(Action setup); + IV3AsyncApiDocumentBuilder WithTag(Action setup); /// /// Marks the to use the specified external documentation /// /// An used to setup the external documentation to use /// The configured - IV3AsyncApiDocumentBuilder WithExternalDocumentation(Action setup); + IV3AsyncApiDocumentBuilder WithExternalDocumentation(Action setup); /// /// Adds the specified to the to build @@ -172,12 +172,12 @@ public interface IV3AsyncApiDocumentBuilder IV3AsyncApiDocumentBuilder WithSecuritySchemeComponent(string name, Action setup); /// - /// Adds the specified reusable to the to build + /// Adds the specified reusable to the to build /// /// The name of the reusable to add - /// An used to setup the reusable to add + /// An used to setup the reusable to add /// The configured - IV3AsyncApiDocumentBuilder WithServerVariableComponent(string name, Action setup); + IV3AsyncApiDocumentBuilder WithServerVariableComponent(string name, Action setup); /// /// Adds the specified reusable to the to build @@ -188,12 +188,12 @@ public interface IV3AsyncApiDocumentBuilder IV3AsyncApiDocumentBuilder WithParameterComponent(string name, Action setup); /// - /// Adds the specified reusable to the to build + /// Adds the specified reusable to the to build /// - /// The name of the reusable to add - /// An used to setup the reusable to add + /// The name of the reusable to add + /// An used to setup the reusable to add /// The configured - IV3AsyncApiDocumentBuilder WithCorrelationIdComponent(string name, Action setup); + IV3AsyncApiDocumentBuilder WithCorrelationIdComponent(string name, Action setup); /// /// Adds the specified reusable to the to build @@ -212,20 +212,20 @@ public interface IV3AsyncApiDocumentBuilder IV3AsyncApiDocumentBuilder WithReplyAddressComponent(string name, Action setup); /// - /// Adds the specified reusable to the to build + /// Adds the specified reusable to the to build /// - /// The name of the reusable to add - /// An used to setup the reusable to add + /// The name of the reusable to add + /// An used to setup the reusable to add /// The configured - IV3AsyncApiDocumentBuilder WithExternalDocumentationComponent(string name, Action setup); + IV3AsyncApiDocumentBuilder WithExternalDocumentationComponent(string name, Action setup); /// - /// Adds the specified reusable to the to build + /// Adds the specified reusable to the to build /// - /// The name of the reusable to add - /// An used to setup the reusable to add + /// The name of the reusable to add + /// An used to setup the reusable to add /// The configured - IV3AsyncApiDocumentBuilder WithTagComponent(string name, Action setup); + IV3AsyncApiDocumentBuilder WithTagComponent(string name, Action setup); /// /// Adds the specified reusable to the to build diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs index eaa4026..c044c93 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs @@ -76,14 +76,14 @@ public interface IV3ChannelDefinitionBuilder /// /// An used to setup the tag to use /// The configured - IV3ChannelDefinitionBuilder WithTag(Action setup); + IV3ChannelDefinitionBuilder WithTag(Action setup); /// /// Marks the to use the specified external documentation /// /// An used to setup the external documentation to use /// The configured - IV3ChannelDefinitionBuilder WithExternalDocumentation(Action setup); + IV3ChannelDefinitionBuilder WithExternalDocumentation(Action setup); /// /// Configures the to use the specified binding diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3CorrelationIdDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3CorrelationIdDefinitionBuilder.cs new file mode 100644 index 0000000..d3859b8 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3CorrelationIdDefinitionBuilder.cs @@ -0,0 +1,43 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3CorrelationIdDefinitionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to use the specified location expression + /// + /// The location expression to use + /// The configured + IV3CorrelationIdDefinitionBuilder WithLocation(string location); + + /// + /// Configures the to use the specified description + /// + /// The description to use + /// The configured + IV3CorrelationIdDefinitionBuilder WithDescription(string? description); + + /// + /// Builds the configured + /// + /// A new + V3CorrelationIdDefinition Build(); + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ExternalDocumentationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ExternalDocumentationDefinitionBuilder.cs new file mode 100644 index 0000000..230925e --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ExternalDocumentationDefinitionBuilder.cs @@ -0,0 +1,43 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3ExternalDocumentationDefinitionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to build to use the specified url + /// + /// The url of the to build + /// The configured + IV3ExternalDocumentationDefinitionBuilder WithUrl(Uri url); + + /// + /// Configures the to build to use the specified description + /// + /// The description of the to build + /// The configured + IV3ExternalDocumentationDefinitionBuilder WithDescription(string? description); + + /// + /// Builds the configured + /// + /// A new + V3ExternalDocumentationDefinition Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageTraitDefinitionBuilder.cs index f703b0a..4728e60 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageTraitDefinitionBuilder.cs @@ -36,7 +36,7 @@ public interface IV3MessageTraitDefinitionBuilder /// /// An used to configure the correlation id to use /// The configured - TBuilder WithCorrelationId(Action setup); + TBuilder WithCorrelationId(Action setup); /// /// Configures the to build to use the specified content type @@ -78,14 +78,14 @@ public interface IV3MessageTraitDefinitionBuilder /// /// An used to setup the tag to use /// The configured - TBuilder WithTag(Action setup); + TBuilder WithTag(Action setup); /// /// Adds the specified external documentation to the to build /// - /// An used to setup the to use + /// An used to setup the to use /// The configured - TBuilder WithExternalDocumentation(Action setup); + TBuilder WithExternalDocumentation(Action setup); /// /// Adds the specified to the to build diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationDefinitionBuilder.cs index 38bc78b..35183f6 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationDefinitionBuilder.cs @@ -55,10 +55,4 @@ public interface IV3OperationDefinitionBuilder /// The configured IV3OperationDefinitionBuilder WithReply(Action setup); - /// - /// Builds the configured - /// - /// A new - V3OperationDefinition Build(); - } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationTraitDefinitionBuilder.cs index 372a5b7..6815461 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationTraitDefinitionBuilder.cs @@ -57,14 +57,14 @@ public interface IV3OperationTraitDefinitionBuilder /// /// An used to setup the tag to use /// The configured - TBuilder WithTag(Action setup); + TBuilder WithTag(Action setup); /// - /// Adds the specified external documentation to the to build + /// Adds the specified external documentation to the to build /// - /// An used to setup the to use + /// An used to setup the to use /// The configured - TBuilder WithExternalDocumentation(Action setup); + TBuilder WithExternalDocumentation(Action setup); /// /// Adds the specified to the to build diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerDefinitionBuilder.cs index 867b307..f3d6392 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerDefinitionBuilder.cs @@ -64,12 +64,12 @@ public interface IV3ServerDefinitionBuilder IV3ServerDefinitionBuilder WithSummary(string? summary); /// - /// Adds the specified to the to build + /// Adds the specified to the to build /// - /// The name of the to add - /// An used to setup the to add + /// The name of the to add + /// An used to setup the to add /// The configured - IV3ServerDefinitionBuilder WithVariable(string name, Action setup); + IV3ServerDefinitionBuilder WithVariable(string name, Action setup); /// /// Configures the to use the specified @@ -83,14 +83,14 @@ public interface IV3ServerDefinitionBuilder /// /// An used to setup the tag to use /// The configured - IV3ServerDefinitionBuilder WithTag(Action setup); + IV3ServerDefinitionBuilder WithTag(Action setup); /// /// Configures the to use the specified external documentation /// /// An used to setup the external documentation to use /// The configured - IV3ServerDefinitionBuilder WithExternalDocumentation(Action setup); + IV3ServerDefinitionBuilder WithExternalDocumentation(Action setup); /// /// Adds the specified to the to build diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerVariableDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerVariableDefinitionBuilder.cs new file mode 100644 index 0000000..45784f5 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerVariableDefinitionBuilder.cs @@ -0,0 +1,57 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3ServerVariableDefinitionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to build to use the specified enum values + /// + /// An array of values to be used if the substitution options are from a limited set. + /// The configured + IV3ServerVariableDefinitionBuilder WithEnumValues(params string[] values); + + /// + /// Configures the to build to use the specified default value + /// + /// The value to use by default for substitution, and to send, if an alternate value is not supplied. + /// The configured + IV3ServerVariableDefinitionBuilder WithDefaultValue(string value); + + /// + /// Configures the to use the specified description + /// + /// The description to use + /// The configured + IV3ServerVariableDefinitionBuilder WithDescription(string? description); + + /// + /// Adds the specified example to the to build + /// + /// The example to add + /// The configured + IV3ServerVariableDefinitionBuilder WithExample(string example); + + /// + /// Builds a new + /// + /// A new + V3ServerVariableDefinition Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3TagDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3TagDefinitionBuilder.cs new file mode 100644 index 0000000..e2f0add --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3TagDefinitionBuilder.cs @@ -0,0 +1,51 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IV3TagDefinitionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Configures the to use the specified name + /// + /// The name to use + /// The configured + IV3TagDefinitionBuilder WithName(string name); + + /// + /// Configures the to use the specified description + /// + /// The description to use + /// The configured + IV3TagDefinitionBuilder WithDescription(string? description); + + /// + /// Adds the specified external documentation to the to build + /// + /// The to the documentation to add + /// The description of the documentation to add + /// The configured + IV3TagDefinitionBuilder WithExternalDocumentation(Uri uri, string? description = null); + + /// + /// Builds a new + /// + /// A new + V3TagDefinition Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/ExternalDocumentationDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V2ExternalDocumentationDefinitionBuilder.cs similarity index 64% rename from src/Neuroglia.AsyncApi.FluentBuilders/ExternalDocumentationDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v3/V2ExternalDocumentationDefinitionBuilder.cs index ce8dd67..f323f52 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/ExternalDocumentationDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V2ExternalDocumentationDefinitionBuilder.cs @@ -11,15 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.AsyncApi.FluentBuilders.v3; + namespace Neuroglia.AsyncApi.FluentBuilders; /// -/// Represents the default implementation of the interface +/// Represents the default implementation of the interface /// /// The current -/// The services used to validate s -public class ExternalDocumentationDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : IExternalDocumentationDefinitionBuilder +/// The services used to validate s +public class V3ExternalDocumentationDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3ExternalDocumentationDefinitionBuilder { /// @@ -28,14 +30,14 @@ public class ExternalDocumentationDefinitionBuilder(IServiceProvider serviceProv protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; /// - /// Gets the services used to validate s + /// Gets the services used to validate s /// - protected virtual IEnumerable> Validators { get; } = validators; + protected virtual IEnumerable> Validators { get; } = validators; /// - /// Gets the to configure + /// Gets the to configure /// - protected virtual ExternalDocumentationDefinition ExternalDocumentation { get; } = new(); + protected virtual V3ExternalDocumentationDefinition ExternalDocumentation { get; } = new(); /// public virtual void Use(string reference) @@ -45,7 +47,7 @@ public virtual void Use(string reference) } /// - public virtual IExternalDocumentationDefinitionBuilder WithUrl(Uri url) + public virtual IV3ExternalDocumentationDefinitionBuilder WithUrl(Uri url) { ArgumentNullException.ThrowIfNull(url); ExternalDocumentation.Url = url; @@ -53,14 +55,14 @@ public virtual IExternalDocumentationDefinitionBuilder WithUrl(Uri url) } /// - public virtual IExternalDocumentationDefinitionBuilder WithDescription(string? description) + public virtual IV3ExternalDocumentationDefinitionBuilder WithDescription(string? description) { ExternalDocumentation.Description = description; return this; } /// - public virtual ExternalDocumentationDefinition Build() + public virtual V3ExternalDocumentationDefinition Build() { var validationResults = Validators.Select(v => v.Validate(ExternalDocumentation)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3AsyncApiDocumentBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3AsyncApiDocumentBuilder.cs new file mode 100644 index 0000000..2d3a6d0 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3AsyncApiDocumentBuilder.cs @@ -0,0 +1,430 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// The services used to validate s +public class V3AsyncApiDocumentBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3AsyncApiDocumentBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected virtual V3AsyncApiDocument Document { get; } = new(); + + /// + public virtual IV3AsyncApiDocumentBuilder WithSpecVersion(string version) + { + ArgumentException.ThrowIfNullOrWhiteSpace(version); + Document.AsyncApi = version; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithId(string? id) + { + Document.Id = id; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithTitle(string title) + { + ArgumentException.ThrowIfNullOrWhiteSpace(title); + Document.Info ??= new(); + Document.Info.Title = title; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithVersion(string version) + { + ArgumentException.ThrowIfNullOrWhiteSpace(version); + Document.Info ??= new(); + Document.Info.Version = version; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithDescription(string? description) + { + Document.Info ??= new(); + Document.Info.Description = description; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithTermsOfService(Uri? uri) + { + Document.Info ??= new(); + Document.Info.TermsOfService = uri; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithContact(string name, Uri? uri = null, string? email = null) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + Document.Info ??= new(); + Document.Info.Contact = new() + { + Name = name, + Url = uri, + Email = email + }; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithLicense(string name, Uri? uri = null) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + Document.Info ??= new(); + Document.Info.License = new() + { + Name = name, + Url = uri + }; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithDefaultContentType(string contentType) + { + ArgumentException.ThrowIfNullOrEmpty(contentType); + Document.DefaultContentType = contentType; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithTag(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Info ??= new(); + Document.Info.Tags ??= []; + Document.Info.Tags.Add(builder.Build()); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithExternalDocumentation(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Info ??= new(); + Document.Info.ExternalDocs = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithServer(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Servers ??= []; + Document.Servers[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithChannel(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Channels ??= []; + Document.Channels[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithOperation(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Operations ??= []; + Document.Operations[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithSchemaComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Schemas ??= []; + Document.Components.Schemas[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithServerComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Servers ??= []; + Document.Components.Servers[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithChannelComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Channels ??= []; + Document.Components.Channels[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithOperationComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Operations ??= []; + Document.Components.Operations[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithMessageComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Messages ??= []; + Document.Components.Messages[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithSecuritySchemeComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.SecuritySchemes ??= []; + Document.Components.SecuritySchemes[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithServerVariableComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.ServerVariables ??= []; + Document.Components.ServerVariables[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithParameterComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Parameters ??= []; + Document.Components.Parameters[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithCorrelationIdComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.CorrelationIds ??= []; + Document.Components.CorrelationIds[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithReplyComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Replies ??= []; + Document.Components.Replies[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithReplyAddressComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.ReplyAddresses ??= []; + Document.Components.ReplyAddresses[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithExternalDocumentationComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.ExternalDocs ??= []; + Document.Components.ExternalDocs[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithTagComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.Tags ??= []; + Document.Components.Tags[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithOperationTraitComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.OperationTraits ??= []; + Document.Components.OperationTraits[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithMessageTraitComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.MessageTraits ??= []; + Document.Components.MessageTraits[name] = builder.Build(); + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithServerBindingsComponent(string name, ServerBindingDefinitionCollection bindings) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(bindings); + Document.Components ??= new(); + Document.Components.ServerBindings ??= []; + Document.Components.ServerBindings[name] = bindings; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithChannelBindingsComponent(string name, ChannelBindingDefinitionCollection bindings) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(bindings); + Document.Components ??= new(); + Document.Components.ChannelBindings ??= []; + Document.Components.ChannelBindings[name] = bindings; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithOperationBindingsComponent(string name, OperationBindingDefinitionCollection bindings) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(bindings); + Document.Components ??= new(); + Document.Components.OperationBindings ??= []; + Document.Components.OperationBindings[name] = bindings; + return this; + } + + /// + public virtual IV3AsyncApiDocumentBuilder WithMessageBindingsComponent(string name, MessageBindingDefinitionCollection bindings) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(bindings); + Document.Components ??= new(); + Document.Components.MessageBindings ??= []; + Document.Components.MessageBindings[name] = bindings; + return this; + } + + /// + public virtual V3AsyncApiDocument Build() + { + var validationResults = Validators.Select(v => v.Validate(Document)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); + return Document; + } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs index 14707b2..85cd681 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs @@ -11,10 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - -using Neuroglia.AsyncApi.FluentBuilders.v2; -using System.Reflection.Metadata; - namespace Neuroglia.AsyncApi.FluentBuilders.v3; /// @@ -113,20 +109,20 @@ public virtual IV3ChannelDefinitionBuilder WithParameter(string name, Action - public virtual IV3ChannelDefinitionBuilder WithExternalDocumentation(Action setup) + public virtual IV3ChannelDefinitionBuilder WithExternalDocumentation(Action setup) { ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); setup(builder); Channel.ExternalDocs = builder.Build(); return this; } /// - public virtual IV3ChannelDefinitionBuilder WithTag(Action setup) + public virtual IV3ChannelDefinitionBuilder WithTag(Action setup) { ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); setup(builder); Channel.Tags ??= []; Channel.Tags.Add(builder.Build()); @@ -150,420 +146,4 @@ public virtual V3ChannelDefinition Build() return Channel; } -} - -/// -/// Represents the default implementation of the interface -/// -/// The current -/// The services used to validate s -public class V3AsyncApiDocumentBuilder(IServiceProvider serviceProvider, IEnumerable> validators) - : IV3AsyncApiDocumentBuilder -{ - - /// - /// Gets the current - /// - protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; - - /// - /// Gets the services used to validate s - /// - protected virtual IEnumerable> Validators { get; } = validators; - - /// - /// Gets the to configure - /// - protected virtual V3AsyncApiDocument Document { get; } = new(); - - /// - public virtual IV3AsyncApiDocumentBuilder WithSpecVersion(string version) - { - ArgumentException.ThrowIfNullOrWhiteSpace(version); - Document.AsyncApi = version; - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithId(string? id) - { - Document.Id = id; - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithTitle(string title) - { - ArgumentException.ThrowIfNullOrWhiteSpace(title); - Document.Info ??= new(); - Document.Info.Title = title; - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithVersion(string version) - { - ArgumentException.ThrowIfNullOrWhiteSpace(version); - Document.Info ??= new(); - Document.Info.Version = version; - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithDescription(string? description) - { - Document.Info ??= new(); - Document.Info.Description = description; - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithTermsOfService(Uri? uri) - { - Document.Info ??= new(); - Document.Info.TermsOfService = uri; - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithContact(string name, Uri? uri = null, string? email = null) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - Document.Info ??= new(); - Document.Info.Contact = new() - { - Name = name, - Url = uri, - Email = email - }; - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithLicense(string name, Uri? uri = null) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - Document.Info ??= new(); - Document.Info.License = new() - { - Name = name, - Url = uri - }; - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithDefaultContentType(string contentType) - { - ArgumentException.ThrowIfNullOrEmpty(contentType); - Document.DefaultContentType = contentType; - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithTag(Action setup) - { - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Info ??= new(); - Document.Info.Tags ??= []; - Document.Info.Tags.Add(builder.Build()); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithExternalDocumentation(Action setup) - { - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Info ??= new(); - Document.Info.ExternalDocs = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithServer(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Servers ??= []; - Document.Servers[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithChannel(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Channels ??= []; - Document.Channels[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithOperation(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Operations ??= []; - Document.Operations[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithSchemaComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.Schemas ??= []; - Document.Components.Schemas[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithServerComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.Servers ??= []; - Document.Components.Servers[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithChannelComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.Channels ??= []; - Document.Components.Channels[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithOperationComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.Operations ??= []; - Document.Components.Operations[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithMessageComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.Messages ??= []; - Document.Components.Messages[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithSecuritySchemeComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.SecuritySchemes ??= []; - Document.Components.SecuritySchemes[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithServerVariableComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.ServerVariables ??= []; - Document.Components.ServerVariables[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithParameterComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.Parameters ??= []; - Document.Components.Parameters[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithCorrelationIdComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.CorrelationIds ??= []; - Document.Components.CorrelationIds[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithReplyComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.Replies ??= []; - Document.Components.Replies[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithReplyAddressComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.ReplyAddresses ??= []; - Document.Components.ReplyAddresses[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithExternalDocumentationComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.ExternalDocs ??= []; - Document.Components.ExternalDocs[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithTagComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.Tags ??= []; - Document.Components.Tags[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithOperationTraitComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.OperationTraits ??= []; - Document.Components.OperationTraits[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithMessageTraitComponent(string name, Action setup) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); - setup(builder); - Document.Components ??= new(); - Document.Components.MessageTraits ??= []; - Document.Components.MessageTraits[name] = builder.Build(); - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithServerBindingsComponent(string name, ServerBindingDefinitionCollection bindings) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(bindings); - Document.Components ??= new(); - Document.Components.ServerBindings ??= []; - Document.Components.ServerBindings[name] = bindings; - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithChannelBindingsComponent(string name, ChannelBindingDefinitionCollection bindings) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(bindings); - Document.Components ??= new(); - Document.Components.ChannelBindings ??= []; - Document.Components.ChannelBindings[name] = bindings; - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithOperationBindingsComponent(string name, OperationBindingDefinitionCollection bindings) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(bindings); - Document.Components ??= new(); - Document.Components.OperationBindings ??= []; - Document.Components.OperationBindings[name] = bindings; - return this; - } - - /// - public virtual IV3AsyncApiDocumentBuilder WithMessageBindingsComponent(string name, MessageBindingDefinitionCollection bindings) - { - ArgumentException.ThrowIfNullOrWhiteSpace(name); - ArgumentNullException.ThrowIfNull(bindings); - Document.Components ??= new(); - Document.Components.MessageBindings ??= []; - Document.Components.MessageBindings[name] = bindings; - return this; - } - - /// - public virtual V3AsyncApiDocument Build() - { - var validationResults = Validators.Select(v => v.Validate(Document)); - if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors!)); - return Document; - } - } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3CorrelationIdDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3CorrelationIdDefinitionBuilder.cs new file mode 100644 index 0000000..fdbb1b2 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3CorrelationIdDefinitionBuilder.cs @@ -0,0 +1,70 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// An containing the services used to validate +public class V3CorrelationIdDefinitionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IV3CorrelationIdDefinitionBuilder +{ + + /// + /// Gets the current + /// + protected IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets an containing the services used to validate + /// + protected IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected V3CorrelationIdDefinition CorrelationId { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + CorrelationId.Reference = reference; + } + + /// + public virtual IV3CorrelationIdDefinitionBuilder WithLocation(string location) + { + ArgumentException.ThrowIfNullOrWhiteSpace(location); + CorrelationId.Location = location; + return this; + } + + /// + public virtual IV3CorrelationIdDefinitionBuilder WithDescription(string? description) + { + CorrelationId.Description = description; + return this; + } + + /// + public virtual V3CorrelationIdDefinition Build() + { + var validationResults = Validators.Select(v => v.Validate(CorrelationId)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); + return CorrelationId; + } + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageTraitDefinitionBuilder.cs index 8e654c0..6880e16 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageTraitDefinitionBuilder.cs @@ -59,10 +59,10 @@ public virtual TBuilder WithHeadersSchema(Action set } /// - public virtual TBuilder WithCorrelationId(Action setup) + public virtual TBuilder WithCorrelationId(Action setup) { ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); setup(builder); Trait.CorrelationId = builder.Build(); return (TBuilder)(object)this; @@ -104,10 +104,10 @@ public virtual TBuilder WithDescription(string? description) } /// - public virtual TBuilder WithTag(Action setup) + public virtual TBuilder WithTag(Action setup) { ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); setup(builder); Trait.Tags ??= []; Trait.Tags.Add(builder.Build()); @@ -115,10 +115,10 @@ public virtual TBuilder WithTag(Action setup) } /// - public virtual TBuilder WithExternalDocumentation(Action setup) + public virtual TBuilder WithExternalDocumentation(Action setup) { ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); setup(builder); Trait.ExternalDocs = builder.Build(); return (TBuilder)(object)this; diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationTraitDefinitionBuilder.cs index 15ed7f0..c923152 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationTraitDefinitionBuilder.cs @@ -81,10 +81,10 @@ public virtual TBuilder WithSecurity(Action } /// - public virtual TBuilder WithTag(Action setup) + public virtual TBuilder WithTag(Action setup) { ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); Trait.Tags ??= []; Trait.Tags.Add(builder.Build()); @@ -92,10 +92,10 @@ public virtual TBuilder WithTag(Action setup) } /// - public virtual TBuilder WithExternalDocumentation(Action setup) + public virtual TBuilder WithExternalDocumentation(Action setup) { ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); Trait.ExternalDocs = builder.Build(); return (TBuilder)(object)this; diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SecuritySchemeDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SecuritySchemeDefinitionBuilder.cs index f65e0cf..2661de5 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SecuritySchemeDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SecuritySchemeDefinitionBuilder.cs @@ -101,7 +101,7 @@ public virtual IV3SecuritySchemeDefinitionBuilder WithBearerFormat(string? forma /// public virtual IV3SecuritySchemeDefinitionBuilder WithOAuthFlows(Action setup) { - ArgumentNullException.ThrowIfNull(nameof(setup)); + ArgumentNullException.ThrowIfNull(setup); var builder = ActivatorUtilities.CreateInstance(ServiceProvider); setup(builder); SecurityScheme.Flows = builder.Build(); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerDefinitionBuilder.cs index f107874..a2adbd3 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerDefinitionBuilder.cs @@ -90,9 +90,9 @@ public virtual IV3ServerDefinitionBuilder WithSummary(string? summary) } /// - public virtual IV3ServerDefinitionBuilder WithVariable(string name, Action setup) + public virtual IV3ServerDefinitionBuilder WithVariable(string name, Action setup) { - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); setup(builder); Server.Variables ??= []; Server.Variables[name] = builder.Build(); @@ -100,20 +100,20 @@ public virtual IV3ServerDefinitionBuilder WithVariable(string name, Action - public virtual IV3ServerDefinitionBuilder WithExternalDocumentation(Action setup) + public virtual IV3ServerDefinitionBuilder WithExternalDocumentation(Action setup) { ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); setup(builder); Server.ExternalDocs = builder.Build(); return this; } /// - public virtual IV3ServerDefinitionBuilder WithTag(Action setup) + public virtual IV3ServerDefinitionBuilder WithTag(Action setup) { ArgumentNullException.ThrowIfNull(setup); - var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); setup(builder); Server.Tags ??= []; Server.Tags.Add(builder.Build()); diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerVariableDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerVariableDefinitionBuilder.cs new file mode 100644 index 0000000..cff97d8 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerVariableDefinitionBuilder.cs @@ -0,0 +1,74 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders.v3; + +/// +/// Represents the default implementation of the interface +/// +/// The services used to validate s +public class V3ServerVariableDefinitionBuilder(IEnumerable> validators) + : IV3ServerVariableDefinitionBuilder +{ + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to build + /// + protected V3ServerVariableDefinition Variable { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + Variable.Reference = reference; + } + + /// + public virtual IV3ServerVariableDefinitionBuilder WithEnumValues(params string[] values) + { + Variable.Enum = new(values); + return this; + } + + /// + public virtual IV3ServerVariableDefinitionBuilder WithDefaultValue(string value) + { + Variable.Default = value; + return this; + } + + /// + public virtual IV3ServerVariableDefinitionBuilder WithDescription(string? description) + { + Variable.Description = description; + return this; + } + + /// + public virtual IV3ServerVariableDefinitionBuilder WithExample(string example) + { + if (string.IsNullOrWhiteSpace(example)) throw new ArgumentNullException(nameof(example)); + Variable.Examples ??= []; + Variable.Examples.Add(example); + return this; + } + + /// + public virtual V3ServerVariableDefinition Build() => Variable; + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/TagDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3TagDefinitionBuilder.cs similarity index 63% rename from src/Neuroglia.AsyncApi.FluentBuilders/TagDefinitionBuilder.cs rename to src/Neuroglia.AsyncApi.FluentBuilders/v3/V3TagDefinitionBuilder.cs index 296f848..4ffc531 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/TagDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3TagDefinitionBuilder.cs @@ -11,28 +11,28 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi.FluentBuilders; +namespace Neuroglia.AsyncApi.FluentBuilders.v3; /// -/// Represents the default implementation of the +/// Represents the default implementation of the /// /// -/// Initializes a new +/// Initializes a new /// -/// An containing the services used to validate s -public class TagDefinitionBuilder(IEnumerable> validators) - : ITagDefinitionBuilder +/// An containing the services used to validate s +public class V3TagDefinitionBuilder(IEnumerable> validators) + : IV3TagDefinitionBuilder { /// - /// Gets the services used to validate s + /// Gets the services used to validate s /// - protected virtual IEnumerable> Validators { get; } = validators; + protected virtual IEnumerable> Validators { get; } = validators; /// - /// Gets the to configure + /// Gets the to configure /// - protected virtual TagDefinition Tag { get; } = new(); + protected virtual V3TagDefinition Tag { get; } = new(); /// public virtual void Use(string reference) @@ -42,7 +42,7 @@ public virtual void Use(string reference) } /// - public virtual ITagDefinitionBuilder WithName(string name) + public virtual IV3TagDefinitionBuilder WithName(string name) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); Tag.Name = name; @@ -50,14 +50,14 @@ public virtual ITagDefinitionBuilder WithName(string name) } /// - public virtual ITagDefinitionBuilder WithDescription(string? description) + public virtual IV3TagDefinitionBuilder WithDescription(string? description) { Tag.Description = description; return this; } /// - public virtual ITagDefinitionBuilder WithExternalDocumentation(Uri uri, string? description = null) + public virtual IV3TagDefinitionBuilder WithExternalDocumentation(Uri uri, string? description = null) { ArgumentNullException.ThrowIfNull(uri); Tag.ExternalDocs = new() { Url = uri, Description = description }; @@ -65,7 +65,7 @@ public virtual ITagDefinitionBuilder WithExternalDocumentation(Uri uri, string? } /// - public virtual TagDefinition Build() + public virtual V3TagDefinition Build() { var validationResults = Validators.Select(v => v.Validate(Tag)); if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); diff --git a/src/Neuroglia.AsyncApi.Validation/v2/TagValidator.cs b/src/Neuroglia.AsyncApi.Validation/v2/TagValidator.cs index f60aafa..7b5a793 100644 --- a/src/Neuroglia.AsyncApi.Validation/v2/TagValidator.cs +++ b/src/Neuroglia.AsyncApi.Validation/v2/TagValidator.cs @@ -14,10 +14,10 @@ namespace Neuroglia.AsyncApi.Validation; /// -/// Represents the service used to validate the +/// Represents the service used to validate the /// public class TagValidator - : AbstractValidator + : AbstractValidator { /// diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Generation/JsonSchemaExampleGeneratorTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Generation/JsonSchemaExampleGeneratorTests.cs index 743b6a3..be7ebcd 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Generation/JsonSchemaExampleGeneratorTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Generation/JsonSchemaExampleGeneratorTests.cs @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.Generation.v2.Interfaces; - namespace Neuroglia.AsyncApi.UnitTests.Cases.Generation; public class JsonSchemaExampleGeneratorTests diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs b/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs index 9e547a9..1f38bea 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Services/AsyncApiDocumentFactory.cs @@ -107,7 +107,7 @@ public static V2AsyncApiDocument CreateV2() }, Tags = [ - new TagDefinition() + new V2TagDefinition() { Name = "fake-tag", Description = "Fake Tag Description", @@ -140,7 +140,7 @@ public static V2AsyncApiDocument CreateV2() }, Tags = [ - new TagDefinition() + new V2TagDefinition() { Name = "fake-tag", Description = "Fake Tag Description", From e859e9fdd805fbff8c873646822c9bb7c02bd905 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Thu, 19 Dec 2024 11:40:10 +0100 Subject: [PATCH 09/21] feat(UnitTests): Added component dereference tests Signed-off-by: Charles d'Avernas --- .../V3AsyncApiDocumentExtensions.cs | 6 +- .../Cases/Core/DereferenceTests.cs | 521 ++++++++++++++++++ .../Neuroglia.AsyncApi.UnitTests.csproj | 1 + 3 files changed, 525 insertions(+), 3 deletions(-) create mode 100644 tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/DereferenceTests.cs diff --git a/src/Neuroglia.AsyncApi.Core/v3/Extensions/V3AsyncApiDocumentExtensions.cs b/src/Neuroglia.AsyncApi.Core/v3/Extensions/V3AsyncApiDocumentExtensions.cs index 238d523..48be889 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/Extensions/V3AsyncApiDocumentExtensions.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/Extensions/V3AsyncApiDocumentExtensions.cs @@ -28,7 +28,7 @@ public static class V3AsyncApiDocumentExtensions public static ReferenceableComponentDefinition Dereference(this V3AsyncApiDocument document, string reference) { ArgumentException.ThrowIfNullOrWhiteSpace(reference); - var componentType = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[^1]; + var componentType = reference.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[^2]; return componentType switch { "servers" => document.DereferenceServer(reference), @@ -42,7 +42,7 @@ public static ReferenceableComponentDefinition Dereference(this V3AsyncApiDocume "correlationIds" => document.DereferenceCorrelationId(reference), "replies" => document.DereferenceReply(reference), "replyAddresses" => document.DereferenceReplyAddress(reference), - "externalDocs" => document.DereferenceExternalDoc(reference), + "externalDocs" => document.DereferenceExternalDocumentation(reference), "tags" => document.DereferenceTag(reference), "operationTraits" => document.DereferenceOperationTrait(reference), "messageTraits" => document.DereferenceMessageTrait(reference), @@ -248,7 +248,7 @@ public static V3OperationReplyAddressDefinition DereferenceReplyAddress(this V3A /// The extended /// The reference to the to get /// The specified - public static V3ExternalDocumentationDefinition DereferenceExternalDoc(this V3AsyncApiDocument document, string reference) + public static V3ExternalDocumentationDefinition DereferenceExternalDocumentation(this V3AsyncApiDocument document, string reference) { ArgumentException.ThrowIfNullOrWhiteSpace(reference); if (!reference.StartsWith("#/components/externalDocs/")) throw new InvalidDataException($"The specified value '{reference}' is not a valid external docs reference"); diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/DereferenceTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/DereferenceTests.cs new file mode 100644 index 0000000..bbba1a1 --- /dev/null +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/DereferenceTests.cs @@ -0,0 +1,521 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Bindings; +using Neuroglia.AsyncApi.FluentBuilders.v3; +using Neuroglia.AsyncApi.v3; + +namespace Neuroglia.AsyncApi.UnitTests.Cases; + +public class DereferenceTests + : IDisposable +{ + + public DereferenceTests() + { + var services = new ServiceCollection(); + services.AddAsyncApi(); + this.ServiceProvider = services.BuildServiceProvider(); + } + + protected ServiceProvider ServiceProvider { get; } + + protected IV3AsyncApiDocumentBuilder DocumentBuilder => this.ServiceProvider.GetRequiredService(); + + [Fact] + public void Dereference_Server_Should_Work() + { + //arrange + var componentName = "fake-server"; + var componentRef = $"#/servers/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithServer(componentName, component => component + .WithTitle("Fake Server")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceServer(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_Channel_Should_Work() + { + //arrange + var componentName = "fake-channel"; + var componentRef = $"#/channels/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithChannel(componentName, component => component + .WithTitle("Fake Channel")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceChannel(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_Operation_Should_Work() + { + //arrange + var componentName = "fake-operation"; + var componentRef = $"#/operations/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithOperation(componentName, component => component + .WithTitle("Fake Operation")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceOperation(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_Server_Component_Should_Work() + { + //arrange + var componentName = "fake-server"; + var componentRef = $"#/components/servers/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithServerComponent(componentName, component => component + .WithTitle("Fake Server")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceServer(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_Channel_Component_Should_Work() + { + //arrange + var componentName = "fake-channel"; + var componentRef = $"#/components/channels/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithChannelComponent(componentName, component => component + .WithTitle("Fake Channel")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceChannel(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_Operation_Component_Should_Work() + { + //arrange + var componentName = "fake-operation"; + var componentRef = $"#/components/operations/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithOperationComponent(componentName, component => component + .WithTitle("Fake Operation")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceOperation(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_Schema_Component_Should_Work() + { + //arrange + var componentName = "fake-schema"; + var componentRef = $"#/components/schemas/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithSchemaComponent(componentName, component => component + .WithFormat("Fake Format")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceSchema(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_Message_Component_Should_Work() + { + //arrange + var componentName = "fake-message"; + var componentRef = $"#/components/messages/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithMessageComponent(componentName, component => component + .WithTitle("Fake Message")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceMessage(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_SecurityScheme_Component_Should_Work() + { + //arrange + var componentName = "fake-security-scheme"; + var componentRef = $"#/components/securitySchemes/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithSecuritySchemeComponent(componentName, component => component + .WithDescription("Fake Security Scheme")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceSecurityScheme(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_ServerVariable_Component_Should_Work() + { + //arrange + var componentName = "fake-server-variable"; + var componentRef = $"#/components/serverVariables/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithServerVariableComponent(componentName, component => component + .WithDescription("Fake Server Variable")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceServerVariable(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_Parameter_Component_Should_Work() + { + //arrange + var componentName = "fake-parameter"; + var componentRef = $"#/components/parameters/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithParameterComponent(componentName, component => component + .WithDescription("Fake Parameter")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceParameter(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_CorrelationId_Component_Should_Work() + { + //arrange + var componentName = "fake-correlationId"; + var componentRef = $"#/components/correlationIds/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithCorrelationIdComponent(componentName, component => component + .WithDescription("Fake Correlation Id")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceCorrelationId(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_Reply_Component_Should_Work() + { + //arrange + var componentName = "fake-reply"; + var componentRef = $"#/components/replies/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithReplyComponent(componentName, component => component + .WithAddress("FakeAddress")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceReply(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_ReplyAddress_Component_Should_Work() + { + //arrange + var componentName = "fake-reply-address"; + var componentRef = $"#/components/replyAddresses/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithReplyAddressComponent(componentName, component => component + .WithDescription("Fake Reply Address")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceReplyAddress(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_ExternalDocs_Component_Should_Work() + { + //arrange + var componentName = "fake-external-docs"; + var componentRef = $"#/components/externalDocs/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithExternalDocumentationComponent(componentName, component => component + .WithDescription("Fake External Docs")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceExternalDocumentation(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_Tag_Component_Should_Work() + { + //arrange + var componentName = "fake-tag"; + var componentRef = $"#/components/tags/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithTagComponent(componentName, component => component + .WithDescription("Fake Tag")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceTag(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_OperationTrait_Component_Should_Work() + { + //arrange + var componentName = "fake-operation-trait"; + var componentRef = $"#/components/operationTraits/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithOperationTraitComponent(componentName, component => component + .WithDescription("Fake Operation Trait")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceOperationTrait(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_MessageTrait_Component_Should_Work() + { + //arrange + var componentName = "fake-message-trait"; + var componentRef = $"#/components/messageTraits/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithMessageTraitComponent(componentName, component => component + .WithDescription("Fake Message Trait")) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceMessageTrait(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_ServerBinding_Component_Should_Work() + { + //arrange + var componentName = "fake-server-binding"; + var componentRef = $"#/components/serverBindings/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithServerBindingsComponent(componentName, new()) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceServerBinding(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_ChannelBinding_Component_Should_Work() + { + //arrange + var componentName = "fake-channel-binding"; + var componentRef = $"#/components/channelBindings/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithChannelBindingsComponent(componentName, new()) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceChannelBinding(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_OperationBinding_Component_Should_Work() + { + //arrange + var componentName = "fake-operation-binding"; + var componentRef = $"#/components/operationBindings/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithOperationBindingsComponent(componentName, new()) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceOperationBinding(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + [Fact] + public void Dereference_MessageBinding_Component_Should_Work() + { + //arrange + var componentName = "fake-message-binding"; + var componentRef = $"#/components/messageBindings/{componentName}"; + var document = this.DocumentBuilder + .WithTitle("fake") + .WithVersion("1.0.0") + .WithMessageBindingsComponent(componentName, new()) + .Build(); + + //act + var dereferenceGeneric = () => document.Dereference(componentRef); + var dereference = () => document.DereferenceMessageBinding(componentRef); + + //assert + dereferenceGeneric.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + dereference.Should().NotThrow().Which.Should().NotBeNull().And.BeOfType(); + } + + void IDisposable.Dispose() + { + this.ServiceProvider.Dispose(); + GC.SuppressFinalize(this); + } + +} diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Neuroglia.AsyncApi.UnitTests.csproj b/tests/Neuroglia.AsyncApi.UnitTests/Neuroglia.AsyncApi.UnitTests.csproj index b598556..1c7e669 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Neuroglia.AsyncApi.UnitTests.csproj +++ b/tests/Neuroglia.AsyncApi.UnitTests/Neuroglia.AsyncApi.UnitTests.csproj @@ -26,6 +26,7 @@ + From f1a3486e68b0fb8450e3a6b53a74075ffdaf7be1 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Thu, 19 Dec 2024 12:23:17 +0100 Subject: [PATCH 10/21] feat(FluentBuilders): Added fluent builders for server, channel, operation and message binding collections Signed-off-by: Charles d'Avernas --- .../Pages/Shared/v2/_V2AsyncApi.cshtml.cs | 12 ---- .../Pages/Shared/v3/_V3AsyncApi.cshtml.cs | 12 ---- .../Pages/Shared/v3/_V3Channel.cshtml.cs | 12 ---- .../Pages/Shared/v3/_V3Operation.cshtml.cs | 12 ---- src/Neuroglia.AsyncApi.Core/v2/V2ApiInfo.cs | 4 +- .../V2ContactDefinition.cs} | 4 +- .../V2LicenseDefinition.cs} | 4 +- src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs | 4 +- .../v3/V3ContactDefinition.cs | 42 +++++++++++++ .../v3/V3LicenseDefinition.cs | 40 ++++++++++++ ...annelBindingDefinitionCollectionBuilder.cs | 63 +++++++++++++++++++ ...annelBindingDefinitionCollectionBuilder.cs | 36 +++++++++++ ...ssageBindingDefinitionCollectionBuilder.cs | 36 +++++++++++ ...ationBindingDefinitionCollectionBuilder.cs | 36 +++++++++++ ...erverBindingDefinitionCollectionBuilder.cs | 36 +++++++++++ ...ssageBindingDefinitionCollectionBuilder.cs | 63 +++++++++++++++++++ ...ationBindingDefinitionCollectionBuilder.cs | 63 +++++++++++++++++++ ...erverBindingDefinitionCollectionBuilder.cs | 63 +++++++++++++++++++ .../Interfaces/IV3AsyncApiDocumentBuilder.cs | 32 ++++++++++ .../Interfaces/IV3ChannelDefinitionBuilder.cs | 7 +++ .../IV3MessageTraitDefinitionBuilder.cs | 7 +++ .../IV3OperationTraitDefinitionBuilder.cs | 7 +++ .../Interfaces/IV3ServerDefinitionBuilder.cs | 9 ++- .../v3/V3AsyncApiDocumentBuilder.cs | 52 +++++++++++++++ .../v3/V3ChannelDefinitionBuilder.cs | 10 +++ .../v3/V3MessageTraitDefinitionBuilder.cs | 10 +++ .../v3/V3OperationTraitDefinitionBuilder.cs | 10 +++ .../v3/V3ServerDefinitionBuilder.cs | 10 +++ .../v2/LicenseValidator.cs | 4 +- .../CloudEvents/CloudEventExtensionsTests.cs | 1 - .../Cases/Core/DereferenceTests.cs | 8 +-- .../Cases/Fluent/FluentBuilderTests.cs | 10 +-- 32 files changed, 650 insertions(+), 69 deletions(-) delete mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml.cs delete mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml.cs delete mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml.cs delete mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml.cs rename src/Neuroglia.AsyncApi.Core/{ContactDefinition.cs => v2/V2ContactDefinition.cs} (96%) rename src/Neuroglia.AsyncApi.Core/{LicenseDefinition.cs => v2/V2LicenseDefinition.cs} (95%) create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3ContactDefinition.cs create mode 100644 src/Neuroglia.AsyncApi.Core/v3/V3LicenseDefinition.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/ChannelBindingDefinitionCollectionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IChannelBindingDefinitionCollectionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageBindingDefinitionCollectionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationBindingDefinitionCollectionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerBindingDefinitionCollectionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/MessageBindingDefinitionCollectionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/OperationBindingDefinitionCollectionBuilder.cs create mode 100644 src/Neuroglia.AsyncApi.FluentBuilders/ServerBindingDefinitionCollectionBuilder.cs diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml.cs deleted file mode 100644 index b9169c8..0000000 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Neuroglia.AsyncApi.AspNetCore.UI.Pages.Shared -{ - public class _V2DocumentModel : PageModel - { - public void OnGet() - { - } - } -} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml.cs deleted file mode 100644 index c091573..0000000 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Neuroglia.AsyncApi.AspNetCore.UI.Pages.Shared -{ - public class V3AsyncApiModel : PageModel - { - public void OnGet() - { - } - } -} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml.cs deleted file mode 100644 index 7171cb8..0000000 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Neuroglia.AsyncApi.AspNetCore.UI.Pages.Shared.v3 -{ - public class _V3ChannelModel : PageModel - { - public void OnGet() - { - } - } -} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml.cs deleted file mode 100644 index 3607c82..0000000 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Neuroglia.AsyncApi.AspNetCore.UI.Pages.Shared.v3 -{ - public class _V3OperationModel : PageModel - { - public void OnGet() - { - } - } -} diff --git a/src/Neuroglia.AsyncApi.Core/v2/V2ApiInfo.cs b/src/Neuroglia.AsyncApi.Core/v2/V2ApiInfo.cs index d8cf295..1faee41 100644 --- a/src/Neuroglia.AsyncApi.Core/v2/V2ApiInfo.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2ApiInfo.cs @@ -50,13 +50,13 @@ public record V2ApiInfo /// Gets/sets the contact information for the exposed API. /// [DataMember(Order = 5, Name = "contact"), JsonPropertyOrder(5), JsonPropertyName("contact"), YamlMember(Order = 5, Alias = "contact")] - public virtual ContactDefinition? Contact { get; set; } + public virtual V2ContactDefinition? Contact { get; set; } /// /// Gets/sets the license information for the exposed API. /// [DataMember(Order = 6, Name = "license"), JsonPropertyOrder(6), JsonPropertyName("license"), YamlMember(Order = 6, Alias = "license")] - public virtual LicenseDefinition? License { get; set; } + public virtual V2LicenseDefinition? License { get; set; } /// public override string ToString() => this.Title; diff --git a/src/Neuroglia.AsyncApi.Core/ContactDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2ContactDefinition.cs similarity index 96% rename from src/Neuroglia.AsyncApi.Core/ContactDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2ContactDefinition.cs index cd8816a..100cb24 100644 --- a/src/Neuroglia.AsyncApi.Core/ContactDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2ContactDefinition.cs @@ -11,13 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi; +namespace Neuroglia.AsyncApi.v2; /// /// Represents an object used to provide contact information for the exposed API /// [DataContract] -public record ContactDefinition +public record V2ContactDefinition { /// diff --git a/src/Neuroglia.AsyncApi.Core/LicenseDefinition.cs b/src/Neuroglia.AsyncApi.Core/v2/V2LicenseDefinition.cs similarity index 95% rename from src/Neuroglia.AsyncApi.Core/LicenseDefinition.cs rename to src/Neuroglia.AsyncApi.Core/v2/V2LicenseDefinition.cs index 55659d4..ee1a55b 100644 --- a/src/Neuroglia.AsyncApi.Core/LicenseDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v2/V2LicenseDefinition.cs @@ -11,13 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace Neuroglia.AsyncApi; +namespace Neuroglia.AsyncApi.v2; /// /// Represents an object used to provide license information for the exposed API /// [DataContract] -public record LicenseDefinition +public record V2LicenseDefinition { /// diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs index 2c6cc73..52bab92 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ApiInfo.cs @@ -50,13 +50,13 @@ public record V3ApiInfo /// Gets/sets the contact information for the exposed API. /// [DataMember(Order = 5, Name = "contact"), JsonPropertyOrder(5), JsonPropertyName("contact"), YamlMember(Order = 5, Alias = "contact")] - public virtual ContactDefinition? Contact { get; set; } + public virtual V3ContactDefinition? Contact { get; set; } /// /// Gets/sets the license information for the exposed API. /// [DataMember(Order = 6, Name = "license"), JsonPropertyOrder(6), JsonPropertyName("license"), YamlMember(Order = 6, Alias = "license")] - public virtual LicenseDefinition? License { get; set; } + public virtual V3LicenseDefinition? License { get; set; } /// /// Gets/sets a list of tags for application API documentation control. Tags can be used for logical grouping of applications. diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ContactDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ContactDefinition.cs new file mode 100644 index 0000000..112a102 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ContactDefinition.cs @@ -0,0 +1,42 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object used to provide contact information for the exposed API +/// +[DataContract] +public record V3ContactDefinition +{ + + /// + /// Gets/sets the identifying name of the contact person/organization. + /// + [DataMember(Order = 1, Name = "name"), JsonPropertyOrder(1), JsonPropertyName("name"), YamlMember(Order = 1, Alias = "name")] + public virtual string? Name { get; set; } + + /// + /// Gets/sets the pointing to the contact information. + /// + [DataMember(Order = 2, Name = "url"), JsonPropertyOrder(2), JsonPropertyName("url"), YamlMember(Order = 2, Alias = "url")] + public virtual Uri? Url { get; set; } + + /// + /// Gets/sets the pointing to the contact information. + /// + [DataType(DataType.EmailAddress)] + [DataMember(Order = 3, Name = "email"), JsonPropertyOrder(3), JsonPropertyName("email"), YamlMember(Order = 3, Alias = "email")] + public virtual string? Email { get; set; } + +} diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3LicenseDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3LicenseDefinition.cs new file mode 100644 index 0000000..ff97709 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Core/v3/V3LicenseDefinition.cs @@ -0,0 +1,40 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.v3; + +/// +/// Represents an object used to provide license information for the exposed API +/// +[DataContract] +public record V3LicenseDefinition +{ + + /// + /// Gets/sets the license name used for the API. + /// + [Required] + [DataMember(Order = 1, Name = "name"), JsonPropertyOrder(1), JsonPropertyName("name"), YamlMember(Order = 1, Alias = "name")] + public virtual string Name { get; set; } = null!; + + /// + /// Gets/sets the to the license used for the API. + /// + [Required] + [DataMember(Order = 2, Name = "url"), JsonPropertyOrder(2), JsonPropertyName("url"), YamlMember(Order = 2, Alias = "url")] + public virtual Uri? Url { get; set; } + + /// + public override string ToString() => Name; + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/ChannelBindingDefinitionCollectionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/ChannelBindingDefinitionCollectionBuilder.cs new file mode 100644 index 0000000..3bc53a6 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/ChannelBindingDefinitionCollectionBuilder.cs @@ -0,0 +1,63 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// An containing the s used to validate built s +public class ChannelBindingDefinitionCollectionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IChannelBindingDefinitionCollectionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected ChannelBindingDefinitionCollection Bindings { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + Bindings.Reference = reference; + } + + /// + public virtual IChannelBindingDefinitionCollectionBuilder WithBinding(IChannelBindingDefinition binding) + { + ArgumentNullException.ThrowIfNull(binding); + Bindings.Add(binding); + return this; + } + + /// + public virtual ChannelBindingDefinitionCollection Build() + { + var validationResults = Validators.Select(v => v.Validate(Bindings)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); + return Bindings; + } + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IChannelBindingDefinitionCollectionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IChannelBindingDefinitionCollectionBuilder.cs new file mode 100644 index 0000000..a664380 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IChannelBindingDefinitionCollectionBuilder.cs @@ -0,0 +1,36 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IChannelBindingDefinitionCollectionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Adds the specified to the to build + /// + /// The to add + /// AThe configured + IChannelBindingDefinitionCollectionBuilder WithBinding(IChannelBindingDefinition binding); + + /// + /// Builds the configured + /// + /// A new + ChannelBindingDefinitionCollection Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageBindingDefinitionCollectionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageBindingDefinitionCollectionBuilder.cs new file mode 100644 index 0000000..6627e8d --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IMessageBindingDefinitionCollectionBuilder.cs @@ -0,0 +1,36 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IMessageBindingDefinitionCollectionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Adds the specified to the to build + /// + /// The to add + /// AThe configured + IMessageBindingDefinitionCollectionBuilder WithBinding(IMessageBindingDefinition binding); + + /// + /// Builds the configured + /// + /// A new + MessageBindingDefinitionCollection Build(); + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationBindingDefinitionCollectionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationBindingDefinitionCollectionBuilder.cs new file mode 100644 index 0000000..43d738f --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IOperationBindingDefinitionCollectionBuilder.cs @@ -0,0 +1,36 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IOperationBindingDefinitionCollectionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Adds the specified to the to build + /// + /// The to add + /// AThe configured + IOperationBindingDefinitionCollectionBuilder WithBinding(IOperationBindingDefinition binding); + + /// + /// Builds the configured + /// + /// A new + OperationBindingDefinitionCollection Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerBindingDefinitionCollectionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerBindingDefinitionCollectionBuilder.cs new file mode 100644 index 0000000..ffae62e --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/Interfaces/IServerBindingDefinitionCollectionBuilder.cs @@ -0,0 +1,36 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders; + +/// +/// Defines the fundamentals of a service used to build s +/// +public interface IServerBindingDefinitionCollectionBuilder + : IReferenceableComponentDefinitionBuilder +{ + + /// + /// Adds the specified to the to build + /// + /// The to add + /// AThe configured + IServerBindingDefinitionCollectionBuilder WithBinding(IServerBindingDefinition binding); + + /// + /// Builds the configured + /// + /// A new + ServerBindingDefinitionCollection Build(); + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/MessageBindingDefinitionCollectionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/MessageBindingDefinitionCollectionBuilder.cs new file mode 100644 index 0000000..097f0f3 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/MessageBindingDefinitionCollectionBuilder.cs @@ -0,0 +1,63 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// An containing the s used to validate built s +public class MessageBindingDefinitionCollectionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IMessageBindingDefinitionCollectionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected MessageBindingDefinitionCollection Bindings { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + Bindings.Reference = reference; + } + + /// + public virtual IMessageBindingDefinitionCollectionBuilder WithBinding(IMessageBindingDefinition binding) + { + ArgumentNullException.ThrowIfNull(binding); + Bindings.Add(binding); + return this; + } + + /// + public virtual MessageBindingDefinitionCollection Build() + { + var validationResults = Validators.Select(v => v.Validate(Bindings)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); + return Bindings; + } + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/OperationBindingDefinitionCollectionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/OperationBindingDefinitionCollectionBuilder.cs new file mode 100644 index 0000000..321a814 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/OperationBindingDefinitionCollectionBuilder.cs @@ -0,0 +1,63 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// An containing the s used to validate built s +public class OperationBindingDefinitionCollectionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IOperationBindingDefinitionCollectionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected OperationBindingDefinitionCollection Bindings { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + Bindings.Reference = reference; + } + + /// + public virtual IOperationBindingDefinitionCollectionBuilder WithBinding(IOperationBindingDefinition binding) + { + ArgumentNullException.ThrowIfNull(binding); + Bindings.Add(binding); + return this; + } + + /// + public virtual OperationBindingDefinitionCollection Build() + { + var validationResults = Validators.Select(v => v.Validate(Bindings)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); + return Bindings; + } + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/ServerBindingDefinitionCollectionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/ServerBindingDefinitionCollectionBuilder.cs new file mode 100644 index 0000000..3f40551 --- /dev/null +++ b/src/Neuroglia.AsyncApi.FluentBuilders/ServerBindingDefinitionCollectionBuilder.cs @@ -0,0 +1,63 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.FluentBuilders; + +/// +/// Represents the default implementation of the interface +/// +/// The current +/// An containing the s used to validate built s +public class ServerBindingDefinitionCollectionBuilder(IServiceProvider serviceProvider, IEnumerable> validators) + : IServerBindingDefinitionCollectionBuilder +{ + + /// + /// Gets the current + /// + protected virtual IServiceProvider ServiceProvider { get; } = serviceProvider; + + /// + /// Gets the services used to validate s + /// + protected virtual IEnumerable> Validators { get; } = validators; + + /// + /// Gets the to configure + /// + protected ServerBindingDefinitionCollection Bindings { get; } = new(); + + /// + public virtual void Use(string reference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(reference); + Bindings.Reference = reference; + } + + /// + public virtual IServerBindingDefinitionCollectionBuilder WithBinding(IServerBindingDefinition binding) + { + ArgumentNullException.ThrowIfNull(binding); + Bindings.Add(binding); + return this; + } + + /// + public virtual ServerBindingDefinitionCollection Build() + { + var validationResults = Validators.Select(v => v.Validate(Bindings)); + if (!validationResults.All(r => r.IsValid)) throw new ValidationException(validationResults.Where(r => !r.IsValid).SelectMany(r => r.Errors)); + return Bindings; + } + +} diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3AsyncApiDocumentBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3AsyncApiDocumentBuilder.cs index 5fe5631..cd55e34 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3AsyncApiDocumentBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3AsyncApiDocumentBuilder.cs @@ -251,6 +251,14 @@ public interface IV3AsyncApiDocumentBuilder /// The configured IV3AsyncApiDocumentBuilder WithServerBindingsComponent(string name, ServerBindingDefinitionCollection bindings); + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the to add + /// The configured + IV3AsyncApiDocumentBuilder WithServerBindingsComponent(string name, Action setup); + /// /// Adds the specified reusable to the to build /// @@ -259,6 +267,14 @@ public interface IV3AsyncApiDocumentBuilder /// The configured IV3AsyncApiDocumentBuilder WithChannelBindingsComponent(string name, ChannelBindingDefinitionCollection bindings); + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the to add + /// The configured + IV3AsyncApiDocumentBuilder WithChannelBindingsComponent(string name, Action setup); + /// /// Adds the specified reusable to the to build /// @@ -267,6 +283,14 @@ public interface IV3AsyncApiDocumentBuilder /// The configured IV3AsyncApiDocumentBuilder WithOperationBindingsComponent(string name, OperationBindingDefinitionCollection bindings); + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the to add + /// The configured + IV3AsyncApiDocumentBuilder WithOperationBindingsComponent(string name, Action setup); + /// /// Adds the specified reusable to the to build /// @@ -275,6 +299,14 @@ public interface IV3AsyncApiDocumentBuilder /// The configured IV3AsyncApiDocumentBuilder WithMessageBindingsComponent(string name, MessageBindingDefinitionCollection bindings); + /// + /// Adds the specified reusable to the to build + /// + /// The name of the reusable to add + /// An used to setup the to add + /// The configured + IV3AsyncApiDocumentBuilder WithMessageBindingsComponent(string name, Action setup); + /// /// Builds the configured /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs index c044c93..1478f6e 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs @@ -92,6 +92,13 @@ public interface IV3ChannelDefinitionBuilder /// The configured IV3ChannelDefinitionBuilder WithBinding(IChannelBindingDefinition binding); + /// + /// Configures the to use the specified + /// + /// An used to setup the to use + /// The configured + IV3ChannelDefinitionBuilder WithBindings(Action setup); + /// /// Builds the configured /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageTraitDefinitionBuilder.cs index 4728e60..2c56706 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3MessageTraitDefinitionBuilder.cs @@ -94,6 +94,13 @@ public interface IV3MessageTraitDefinitionBuilder /// The configured TBuilder WithBinding(IMessageBindingDefinition binding); + /// + /// Configures the to use the specified + /// + /// An used to setup the to use + /// The configured + TBuilder WithBindings(Action setup); + /// /// Adds the specified example to the to build /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationTraitDefinitionBuilder.cs index 6815461..420ee9b 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3OperationTraitDefinitionBuilder.cs @@ -73,6 +73,13 @@ public interface IV3OperationTraitDefinitionBuilder /// The configured TBuilder WithBinding(IOperationBindingDefinition binding); + /// + /// Configures the to use the specified + /// + /// An used to setup the to use + /// The configured + TBuilder WithBindings(Action setup); + /// /// Builds a new /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerDefinitionBuilder.cs index f3d6392..40a94b0 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ServerDefinitionBuilder.cs @@ -99,10 +99,17 @@ public interface IV3ServerDefinitionBuilder /// The configured IV3ServerDefinitionBuilder WithBinding(IServerBindingDefinition binding); + /// + /// Configures the to use the specified + /// + /// An used to setup the to use + /// The configured + IV3ServerDefinitionBuilder WithBindings(Action setup); + /// /// Builds the configured /// /// A new V3ServerDefinition Build(); -} +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3AsyncApiDocumentBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3AsyncApiDocumentBuilder.cs index 2d3a6d0..8c5c267 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3AsyncApiDocumentBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3AsyncApiDocumentBuilder.cs @@ -386,6 +386,19 @@ public virtual IV3AsyncApiDocumentBuilder WithServerBindingsComponent(string nam return this; } + /// + public virtual IV3AsyncApiDocumentBuilder WithServerBindingsComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.ServerBindings ??= []; + Document.Components.ServerBindings[name] = builder.Build(); + return this; + } + /// public virtual IV3AsyncApiDocumentBuilder WithChannelBindingsComponent(string name, ChannelBindingDefinitionCollection bindings) { @@ -397,6 +410,19 @@ public virtual IV3AsyncApiDocumentBuilder WithChannelBindingsComponent(string na return this; } + /// + public virtual IV3AsyncApiDocumentBuilder WithChannelBindingsComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.ChannelBindings ??= []; + Document.Components.ChannelBindings[name] = builder.Build(); + return this; + } + /// public virtual IV3AsyncApiDocumentBuilder WithOperationBindingsComponent(string name, OperationBindingDefinitionCollection bindings) { @@ -408,6 +434,19 @@ public virtual IV3AsyncApiDocumentBuilder WithOperationBindingsComponent(string return this; } + /// + public virtual IV3AsyncApiDocumentBuilder WithOperationBindingsComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.OperationBindings ??= []; + Document.Components.OperationBindings[name] = builder.Build(); + return this; + } + /// public virtual IV3AsyncApiDocumentBuilder WithMessageBindingsComponent(string name, MessageBindingDefinitionCollection bindings) { @@ -419,6 +458,19 @@ public virtual IV3AsyncApiDocumentBuilder WithMessageBindingsComponent(string na return this; } + /// + public virtual IV3AsyncApiDocumentBuilder WithMessageBindingsComponent(string name, Action setup) + { + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Document.Components ??= new(); + Document.Components.MessageBindings ??= []; + Document.Components.MessageBindings[name] = builder.Build(); + return this; + } + /// public virtual V3AsyncApiDocument Build() { diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs index 85cd681..662c583 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs @@ -138,6 +138,16 @@ public virtual IV3ChannelDefinitionBuilder WithBinding(IChannelBindingDefinition return this; } + /// + public virtual IV3ChannelDefinitionBuilder WithBindings(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Channel.Bindings = builder.Build(); + return this; + } + /// public virtual V3ChannelDefinition Build() { diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageTraitDefinitionBuilder.cs index 6880e16..c50667c 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3MessageTraitDefinitionBuilder.cs @@ -133,6 +133,16 @@ public virtual TBuilder WithBinding(IMessageBindingDefinition binding) return (TBuilder)(object)this; } + /// + public virtual TBuilder WithBindings(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Trait.Bindings = builder.Build(); + return (TBuilder)(object)this; + } + /// public virtual TBuilder WithExample(Action setup) { diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationTraitDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationTraitDefinitionBuilder.cs index c923152..d69bfaf 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationTraitDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3OperationTraitDefinitionBuilder.cs @@ -110,6 +110,16 @@ public virtual TBuilder WithBinding(IOperationBindingDefinition binding) return (TBuilder)(object)this; } + /// + public virtual TBuilder WithBindings(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Trait.Bindings = builder.Build(); + return (TBuilder)(object)this; + } + /// public virtual TTrait Build() { diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerDefinitionBuilder.cs index a2adbd3..575611c 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ServerDefinitionBuilder.cs @@ -140,6 +140,16 @@ public virtual IV3ServerDefinitionBuilder WithBinding(IServerBindingDefinition b return this; } + /// + public virtual IV3ServerDefinitionBuilder WithBindings(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = ActivatorUtilities.CreateInstance(this.ServiceProvider); + setup(builder); + Server.Bindings = builder.Build(); + return this; + } + /// public virtual V3ServerDefinition Build() { diff --git a/src/Neuroglia.AsyncApi.Validation/v2/LicenseValidator.cs b/src/Neuroglia.AsyncApi.Validation/v2/LicenseValidator.cs index 4953eb2..7b82167 100644 --- a/src/Neuroglia.AsyncApi.Validation/v2/LicenseValidator.cs +++ b/src/Neuroglia.AsyncApi.Validation/v2/LicenseValidator.cs @@ -14,10 +14,10 @@ namespace Neuroglia.AsyncApi.Validation; /// -/// Represents the service used to validate the +/// Represents the service used to validate the /// public class LicenseValidator - : AbstractValidator + : AbstractValidator { /// diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/CloudEvents/CloudEventExtensionsTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/CloudEvents/CloudEventExtensionsTests.cs index b132f56..7b321e9 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/CloudEvents/CloudEventExtensionsTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/CloudEvents/CloudEventExtensionsTests.cs @@ -13,7 +13,6 @@ using Neuroglia.AsyncApi.Bindings.Http; using Neuroglia.AsyncApi.FluentBuilders.v2; -using Neuroglia.AsyncApi.FluentBuilders.v2; namespace Neuroglia.AsyncApi.UnitTests.Cases.CloudEvents; diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/DereferenceTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/DereferenceTests.cs index bbba1a1..c3b55f6 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/DereferenceTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Core/DereferenceTests.cs @@ -437,7 +437,7 @@ public void Dereference_ServerBinding_Component_Should_Work() var document = this.DocumentBuilder .WithTitle("fake") .WithVersion("1.0.0") - .WithServerBindingsComponent(componentName, new()) + .WithServerBindingsComponent(componentName, new ServerBindingDefinitionCollection()) .Build(); //act @@ -458,7 +458,7 @@ public void Dereference_ChannelBinding_Component_Should_Work() var document = this.DocumentBuilder .WithTitle("fake") .WithVersion("1.0.0") - .WithChannelBindingsComponent(componentName, new()) + .WithChannelBindingsComponent(componentName, new ChannelBindingDefinitionCollection()) .Build(); //act @@ -479,7 +479,7 @@ public void Dereference_OperationBinding_Component_Should_Work() var document = this.DocumentBuilder .WithTitle("fake") .WithVersion("1.0.0") - .WithOperationBindingsComponent(componentName, new()) + .WithOperationBindingsComponent(componentName, new OperationBindingDefinitionCollection()) .Build(); //act @@ -500,7 +500,7 @@ public void Dereference_MessageBinding_Component_Should_Work() var document = this.DocumentBuilder .WithTitle("fake") .WithVersion("1.0.0") - .WithMessageBindingsComponent(componentName, new()) + .WithMessageBindingsComponent(componentName, new MessageBindingDefinitionCollection()) .Build(); //act diff --git a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs index b472e94..bfc11d6 100644 --- a/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs +++ b/tests/Neuroglia.AsyncApi.UnitTests/Cases/Fluent/FluentBuilderTests.cs @@ -68,7 +68,7 @@ public void Build_AsyncApiDocument_V2_Should_Work() var channelParameterName = "fakeChannelParam"; var channelParameterLocation = "/MQMD/CorrelId"; var channelParameterDescription = "Fake Channel Param Description"; - var channelParameterSchema = new JsonSchemaBuilder().FromType(); + var channelParameterSchema = new JsonSchemaBuilder().FromType(); var publishOperationId = "fake-publish-operation"; var publishOperationDescription = "Fake Publish Operation Description"; var publishOperationSummary = "Fake Publish Operation Summary"; @@ -109,7 +109,7 @@ public void Build_AsyncApiDocument_V2_Should_Work() .WithSummary(publishOperationSummary) .WithBinding(new HttpOperationBindingDefinition()) .WithMessage(message => message - .WithPayloadOfType())) + .WithPayloadOfType())) .WithSubscribeOperation(subscribe => subscribe .WithOperationId(subscribeOperationId) .WithDescription(subscribeOperationDescription) @@ -117,8 +117,8 @@ public void Build_AsyncApiDocument_V2_Should_Work() .WithBinding(new HttpOperationBindingDefinition()) .WithMessages ( - message1 => message1.WithPayloadOfType(), - message2 => message2.WithPayloadOfType() + message1 => message1.WithPayloadOfType(), + message2 => message2.WithPayloadOfType() ))) .WithTag(tag => tag .WithName(tagName) @@ -229,7 +229,7 @@ public void Build_AsyncApiDocument_V3_Should_Work() var channelParameterName = "fakeChannelParam"; var channelParameterLocation = "/MQMD/CorrelId"; var channelParameterDescription = "Fake Channel Param Description"; - var channelParameterSchema = new JsonSchemaBuilder().FromType(); + var channelParameterSchema = new JsonSchemaBuilder().FromType(); var sendMessageName = "fake-receive-message"; var sendOperationName = "fake-send-operation"; var sendOperationChannelRef = $"#/channels/{channelName}"; From 511aac3da1f5e8c2a9b25b7cfa0f78c97e2e5063 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Thu, 19 Dec 2024 17:39:33 +0100 Subject: [PATCH 11/21] feat(UI): Updated all V3 component views Signed-off-by: Charles d'Avernas --- .../Messages/AddStreetLightRequest.cs | 34 ++ samples/StreetLightsApi/Program.cs | 44 ++- .../Services/StreetLightsService.cs | 6 +- .../StreetLightsApi/StreetLightsApi.csproj | 4 +- .../V2CorrelationIdDefinitionViewModel.cs} | 8 +- .../V2SchemaViewModel.cs} | 8 +- .../Models/v3/V3AsyncApiDocumentViewModel.cs | 15 +- .../V3BindingDefinitionCollectionViewModel.cs | 29 ++ .../Models/v3/V3BindingDefinitionViewModel.cs | 18 +- .../Models/v3/V3ChannelDefinitionViewModel.cs | 20 +- .../Models/v3/V3ComponentsViewModel.cs | 28 ++ .../v3/V3CorrelationIdDefinitionViewModel.cs | 28 ++ .../Models/v3/V3JsonSchemaViewModel.cs | 29 ++ .../v3/V3MessageDefinitionViewModel .cs | 28 ++ .../v3/V3OperationDefinitionViewModel.cs | 18 +- .../V3OperationMessageDefinitionViewModel.cs | 27 ++ .../Models/v3/V3SchemaViewModel.cs} | 25 +- .../Models/v3/V3ServerDefinitionViewModel.cs | 19 +- .../Pages/Shared/_Layout.cshtml | 8 +- .../Pages/Shared/v2/_V2AsyncApi.cshtml | 4 +- .../_V2CorrelationId.cshtml} | 2 +- .../Pages/Shared/v2/_V2Message.cshtml | 4 +- .../{_Schema.cshtml => v2/_V2Schema.cshtml} | 2 +- .../Pages/Shared/v2/_V2Server.cshtml | 2 +- .../Pages/Shared/v3/_V3AsyncApi.cshtml | 41 +- .../Pages/Shared/v3/_V3Binding.cshtml | 2 +- .../Shared/v3/_V3BindingCollection.cshtml | 23 ++ .../Pages/Shared/v3/_V3Channel.cshtml | 104 +++++- .../Pages/Shared/v3/_V3Components.cshtml | 350 ++++++++++++++++++ .../Pages/Shared/v3/_V3CorrelationId.cshtml | 21 ++ .../Pages/Shared/v3/_V3JsonSchema.cshtml | 75 ++++ .../Pages/Shared/v3/_V3Message.cshtml | 88 +++++ .../Pages/Shared/v3/_V3Operation.cshtml | 45 ++- .../Shared/v3/_V3OperationMessage.cshtml | 86 +++++ .../Pages/Shared/v3/_V3Schema.cshtml | 45 +++ .../Pages/Shared/v3/_V3Server.cshtml | 55 ++- .../Bindings/BindingDefinitionCollection.cs | 2 + .../Bindings/IBindingDefinitionCollection.cs | 23 +- .../v3/Attributes/AsyncApiV3Attribute.cs | 5 + .../Attributes/ChannelParameterV3Attribute.cs | 5 + .../v3/Attributes/ChannelV3Attribute.cs | 12 +- .../v3/Attributes/MessageV3Attribute.cs | 32 +- .../v3/Attributes/OperationV3Attribute.cs | 33 +- .../V3AsyncApiDocumentExtensions.cs | 27 ++ .../v3/V3ChannelDefinition.cs | 2 +- .../Interfaces/IV3ChannelDefinitionBuilder.cs | 2 +- .../IV3ParameterDefinitionBuilder.cs | 2 +- .../Interfaces/IV3SchemaDefinitionBuilder.cs | 6 + .../v3/V3ChannelDefinitionBuilder.cs | 3 +- .../v3/V3ParameterDefinitionBuilder.cs | 3 +- .../v3/V3SchemaDefinitionBuilder.cs | 10 + .../AsyncApiDocumentGenerator.v2.cs | 6 +- .../AsyncApiDocumentGenerator.v3.cs | 225 +++++++---- .../JsonSchemaGeneratorConfiguration.cs | 57 +++ 54 files changed, 1565 insertions(+), 235 deletions(-) create mode 100644 samples/StreetLightsApi/Messages/AddStreetLightRequest.cs rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/{CorrelationIdDefinitionViewModel.cs => v2/V2CorrelationIdDefinitionViewModel.cs} (75%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/{SchemaViewModel.cs => v2/V2SchemaViewModel.cs} (78%) create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionCollectionViewModel.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ComponentsViewModel.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3CorrelationIdDefinitionViewModel.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3JsonSchemaViewModel.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageDefinitionViewModel .cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationMessageDefinitionViewModel.cs rename src/{Neuroglia.AsyncApi.Generation/DateTimeOffsetJsonSchemaGenerator.cs => Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SchemaViewModel.cs} (51%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/{_CorrelationId.cshtml => v2/_V2CorrelationId.cshtml} (93%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/{_Schema.cshtml => v2/_V2Schema.cshtml} (99%) create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3BindingCollection.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Components.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3CorrelationId.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3JsonSchema.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Message.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3OperationMessage.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Schema.cshtml create mode 100644 src/Neuroglia.AsyncApi.Generation/JsonSchemaGeneratorConfiguration.cs diff --git a/samples/StreetLightsApi/Messages/AddStreetLightRequest.cs b/samples/StreetLightsApi/Messages/AddStreetLightRequest.cs new file mode 100644 index 0000000..1624ca3 --- /dev/null +++ b/samples/StreetLightsApi/Messages/AddStreetLightRequest.cs @@ -0,0 +1,34 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace StreetLightsApi.Messages; + +public class AddStreetLightRequest +{ + + /// + /// Gets/sets the id of the street to add a new light to + /// + public required string StreetId { get; init; } + + /// + /// Gets/sets the latitude of the light to add + /// + public required decimal Latitude { get; init; } + + /// + /// Gets/sets the longitude of the light to add + /// + public required decimal Longitude { get; init; } + +} diff --git a/samples/StreetLightsApi/Program.cs b/samples/StreetLightsApi/Program.cs index 064d635..53b119d 100644 --- a/samples/StreetLightsApi/Program.cs +++ b/samples/StreetLightsApi/Program.cs @@ -11,7 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Json.Schema.Generation; using Neuroglia.AsyncApi.Bindings.Mqtt; +using StreetLightsApi.Messages; var builder = WebApplication.CreateBuilder(args); @@ -64,7 +66,47 @@ { ClientId = "StreetLightsAPI:1.0.0", CleanSession = true - })); + })) + .WithServerComponent("http", server => server + .WithHost("https://test.com") + .WithPathName("/{environment}") + .WithProtocol(AsyncApiProtocol.Http) + .WithDescription("The **HTTP test server**. Use the `env` variable to point to either `production` or `staging`.") + .WithVariable("environment", variable => variable + .WithDescription("Environment to connect to.") + .WithEnumValues("production", "staging")) + .WithBindings(bindings => bindings + .Use("#/components/serverBindings/http"))) + .WithChannelComponent("lightingMeasuredHTTP", channel => channel + .WithDescription("This channel is used to exchange messages about lightning measurements.") + .WithServer("#/components/servers/http") + .WithBindings(bindings => bindings + .Use("#/components/channelBindings/http"))) + .WithOperationComponent("addStreetLight", operation => operation + .WithAction(Neuroglia.AsyncApi.v3.V3OperationAction.Receive) + .WithChannel("#/components/channels/lightingMeasuredHTTP") + .WithDescription("Adds a new **streetlight** to the API.") + .WithMessage("#/components/messages/addStreetLightRequest") + .WithBindings(bindings => bindings + .Use("#/components/operationBindings/http"))) + .WithMessageComponent("addStreetLightRequest", message => message + .WithPayloadSchema(schema => schema + .WithJsonSchema(jsonSchema => jsonSchema + .FromType(Neuroglia.AsyncApi.JsonSchemaGeneratorConfiguration.Default))) + .WithBindings(bindings => bindings + .Use("#/components/messageBindings/http"))) + .WithServerBindingsComponent("http", bindings => bindings + .WithBinding(new HttpServerBindingDefinition())) + .WithChannelBindingsComponent("http", bindings => bindings + .WithBinding(new HttpChannelBindingDefinition())) + .WithOperationBindingsComponent("http", bindings => bindings + .WithBinding(new HttpOperationBindingDefinition() + { + Method = Neuroglia.AsyncApi.Bindings.Http.HttpMethod.POST, + Type = HttpBindingOperationType.Request + })) + .WithMessageBindingsComponent("http", bindings => bindings + .WithBinding(new HttpMessageBindingDefinition())); })); builder.Services.AddAsyncApiDocument(document => document .WithTitle("Cloud Event API") diff --git a/samples/StreetLightsApi/Services/StreetLightsService.cs b/samples/StreetLightsApi/Services/StreetLightsService.cs index 8d5171a..0d3b100 100644 --- a/samples/StreetLightsApi/Services/StreetLightsService.cs +++ b/samples/StreetLightsApi/Services/StreetLightsService.cs @@ -18,7 +18,7 @@ namespace StreetLightsApi.Server.Services; [AsyncApiV2("Streetlights API", "1.0.0", Description = "The Smartylighting Streetlights API allows you to remotely manage the city lights.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] [AsyncApiV3("Streetlights API", "1.0.0", Description = "The **Smartylighting Streetlights API** allows you to remotely manage the city lights.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] -[ChannelV3("lightingMeasured", Address = "streets.{streetName}", Description = "This channel is used to exchange messages about lightning measurements.", Servers = ["#/servers/mosquitto"])] +[ChannelV3("lightingMeasuredMQTT", Address = "streets.{streetName}", Description = "This channel is used to exchange messages about lightning measurements.", Servers = ["#/servers/mosquitto"])] [ChannelParameterV3("lightingMeasured", "streetName", Description = "The name of the **street** the lights to get measurements for are located in")] public class StreetLightsService(ILogger logger, IJsonSerializer serializer) : BackgroundService @@ -47,7 +47,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) } [ChannelV2("light/measured"), PublishOperationV2(OperationId = "NotifyLightMeasured", Summary = "Notifies remote consumers about environmental lighting conditions for a particular streetlight."), TagV2("light", "A tag for light-related operations"), TagV2("measurement", "A tag for measurement-related operations")] - [OperationV3("sendLightMeasurement", V3OperationAction.Send, "#/channels/lightingMeasured", Description = "Notifies remote **consumers** about environmental lighting conditions for a particular **streetlight**."), TagV3(Reference = "#/components/tags/measurement")] + [OperationV3("sendLightMeasurement", V3OperationAction.Send, "#/channels/lightingMeasuredMQTT", Description = "Notifies remote **consumers** about environmental lighting conditions for a particular **streetlight**."), TagV3(Reference = "#/components/tags/measurement")] public async Task PublishLightMeasured(LightMeasuredEvent e, CancellationToken cancellationToken = default) { var message = new MqttApplicationMessage() @@ -60,7 +60,7 @@ public async Task PublishLightMeasured(LightMeasuredEvent e, CancellationToken c } [ChannelV2("light/measured"), SubscribeOperationV2(OperationId = "OnLightMeasured", Summary = "Inform about environmental lighting conditions for a particular streetlight"), TagV2("light", "A tag for light-related operations"), TagV2("measurement", "A tag for measurement-related operations")] - [OperationV3("receiveLightMeasurement", V3OperationAction.Receive, "#/channels/lightingMeasured"), TagV3(Reference = "#/components/tags/measurement")] + [OperationV3("receiveLightMeasurement", V3OperationAction.Receive, "#/channels/lightingMeasuredMQTT"), TagV3(Reference = "#/components/tags/measurement")] protected Task OnLightMeasured(LightMeasuredEvent e) { this.Logger.LogInformation("Event received:\r\n{json}", this.Serializer.SerializeToText(e)); diff --git a/samples/StreetLightsApi/StreetLightsApi.csproj b/samples/StreetLightsApi/StreetLightsApi.csproj index 51aa229..3f13ae3 100644 --- a/samples/StreetLightsApi/StreetLightsApi.csproj +++ b/samples/StreetLightsApi/StreetLightsApi.csproj @@ -1,9 +1,11 @@ - + net9.0 enable enable + false + True diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2CorrelationIdDefinitionViewModel.cs similarity index 75% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2CorrelationIdDefinitionViewModel.cs index bfe53e9..61b271f 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/CorrelationIdDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2CorrelationIdDefinitionViewModel.cs @@ -11,19 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; - -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render an view /// -public record CorrelationIdDefinitionViewModel +public record V2CorrelationIdDefinitionViewModel : V2AsyncApiDocumentViewModel { /// - public CorrelationIdDefinitionViewModel(V2AsyncApiDocument document, V2CorrelationIdDefinition correlationId) : base(document) { this.CorrelationId = correlationId; } + public V2CorrelationIdDefinitionViewModel(V2AsyncApiDocument document, V2CorrelationIdDefinition correlationId) : base(document) { CorrelationId = correlationId; } /// /// Gets the to render diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SchemaViewModel.cs similarity index 78% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SchemaViewModel.cs index 8bf0bbc..516c16d 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SchemaViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SchemaViewModel.cs @@ -11,19 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; - -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render a view /// -public record SchemaViewModel +public record V2SchemaViewModel : V2AsyncApiDocumentViewModel { /// - public SchemaViewModel(V2AsyncApiDocument document, JsonSchema schema) : base(document) => this.Schema = schema; + public V2SchemaViewModel(V2AsyncApiDocument document, JsonSchema schema) : base(document) => Schema = schema; /// /// Gets the to render diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs index a2ec0ae..6bd068d 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs @@ -11,25 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.v3; - namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; /// /// Holds the data used to render an view /// -public record V3AsyncApiDocumentViewModel +/// The to render the view for +public record V3AsyncApiDocumentViewModel(V3AsyncApiDocument Document) { - /// - /// Initializes a new - /// - /// The to render the view for - public V3AsyncApiDocumentViewModel(V3AsyncApiDocument document) => Document = document; - - /// - /// Gets the to render the view for - /// - public V3AsyncApiDocument Document { get; } } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionCollectionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionCollectionViewModel.cs new file mode 100644 index 0000000..fdab2f0 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionCollectionViewModel.cs @@ -0,0 +1,29 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The that defines the to render +/// A reference to the component that defines the to render +/// The name of the to render +/// The to render +public record V3BindingDefinitionCollectionViewModel(V3AsyncApiDocument Document, string ComponentReference, string BindingCollectionName, IBindingDefinitionCollection BindingCollection) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionViewModel.cs index 3d7850b..07ae64e 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3BindingDefinitionViewModel.cs @@ -16,21 +16,13 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; /// /// Holds the data used to render an view /// -public record V3BindingDefinitionViewModel - : V3AsyncApiDocumentViewModel +/// The that defines the to render +/// The to render +/// The component the is defined by +public record V3BindingDefinitionViewModel(V3AsyncApiDocument Document, IBindingDefinition Binding, string ParentRef) + : V3AsyncApiDocumentViewModel(Document) { - /// - public V3BindingDefinitionViewModel(V3AsyncApiDocument document, IBindingDefinition binding, string parentRef) : base(document) { Binding = binding; ParentRef = parentRef; } - /// - /// Gets the to render - /// - public IBindingDefinition Binding { get; } - - /// - /// Gets the reference of the 's parent component - /// - public string ParentRef { get; } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ChannelDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ChannelDefinitionViewModel.cs index c11f86f..4c48aa5 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ChannelDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ChannelDefinitionViewModel.cs @@ -16,21 +16,13 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; /// /// Holds the data used to render an view /// -/// The document the to render belongs to -/// The name of the to render -/// The to render -public record V3ChannelDefinitionViewModel(V3AsyncApiDocument document, string channelName, V3ChannelDefinition channel) - : V3AsyncApiDocumentViewModel(document) +/// The document the to render belongs to +/// The path to the to render +/// The name of the to render +/// The to render +public record V3ChannelDefinitionViewModel(V3AsyncApiDocument Document, string Path, string Name, V3ChannelDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) { - /// - /// Gets the name of the to render - /// - public string ChannelName { get; } = channelName; - - /// - /// Gets the to render - /// - public V3ChannelDefinition Channel { get; } = channel; } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ComponentsViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ComponentsViewModel.cs new file mode 100644 index 0000000..938408f --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ComponentsViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; + +/// +/// Holds the data used to render an view +/// +/// The the to render belongs to +public record V3ComponentsViewModel(V3AsyncApiDocument Document) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3CorrelationIdDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3CorrelationIdDefinitionViewModel.cs new file mode 100644 index 0000000..7e0f9f1 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3CorrelationIdDefinitionViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; + +/// +/// Holds the data used to render an view +/// +/// The the to render belongs to +/// The to render +public record V3CorrelationIdDefinitionViewModel(V3AsyncApiDocument Document, V3CorrelationIdDefinition CorrelationId) + : V3AsyncApiDocumentViewModel(Document) +{ + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3JsonSchemaViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3JsonSchemaViewModel.cs new file mode 100644 index 0000000..53f8265 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3JsonSchemaViewModel.cs @@ -0,0 +1,29 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data required to render a view +/// +/// The that defines the to render +/// The to render +/// A reference to the component that defines the +/// An containing examples of the to render +public record V3SchemaViewModel(V3AsyncApiDocument Document, V3SchemaDefinition SchemaDefinition, string ParentReference, IEnumerable? Examples = null) + : V3AsyncApiDocument(Document) +{ + + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageDefinitionViewModel .cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageDefinitionViewModel .cs new file mode 100644 index 0000000..5e0accc --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageDefinitionViewModel .cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render a view +/// +/// The that defines the to render +/// The name of the to render +/// The to render +public record V3MessageDefinitionViewModel(V3AsyncApiDocument Document, string MessageName, V3MessageDefinition Message) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationDefinitionViewModel.cs index b5512a9..c07e9d0 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationDefinitionViewModel.cs @@ -16,21 +16,13 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; /// /// Holds the data used to render a view /// -/// The that defines the to render -/// The name of the to render -/// The to render -public record V3OperationDefinitionViewModel(V3AsyncApiDocument document, string operationName, V3OperationDefinition operation) - : V3AsyncApiDocumentViewModel(document) +/// The that defines the to render +/// The name of the to render +/// The to render +public record V3OperationDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3OperationDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) { - /// - /// Gets the name of the to render - /// - public string OperationName { get; } = operationName; - /// - /// Gets the to render - /// - public V3OperationDefinition Operation { get; } = operation; } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationMessageDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationMessageDefinitionViewModel.cs new file mode 100644 index 0000000..c350042 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationMessageDefinitionViewModel.cs @@ -0,0 +1,27 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render a 's view +/// +/// The that defines the to render +/// The index of the to render within its parent +/// A reference to the to render +/// The to render +public record V3OperationMessageDefinitionViewModel(V3AsyncApiDocument Document, int Index, string Reference, V3MessageDefinition Message) + : V3AsyncApiDocumentViewModel(Document) +{ + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Generation/DateTimeOffsetJsonSchemaGenerator.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SchemaViewModel.cs similarity index 51% rename from src/Neuroglia.AsyncApi.Generation/DateTimeOffsetJsonSchemaGenerator.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SchemaViewModel.cs index 14e097b..5e223a1 100644 --- a/src/Neuroglia.AsyncApi.Generation/DateTimeOffsetJsonSchemaGenerator.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SchemaViewModel.cs @@ -11,26 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Json.Schema.Generation.Generators; -using Json.Schema.Generation.Intents; - -namespace Neuroglia.AsyncApi.Generation; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; /// -/// Represents an used to generate s for s +/// Holds the data used to render a view /// -public class DateTimeOffsetJsonSchemaGenerator - : ISchemaGenerator +public record V3JsonSchemaViewModel + : V3AsyncApiDocumentViewModel { /// - public virtual bool Handles(Type type) => type == typeof(DateTimeOffset); + public V3JsonSchemaViewModel(V3AsyncApiDocument document, JsonSchema schema) : base(document) => Schema = schema; - /// - public virtual void AddConstraints(SchemaGenerationContextBase context) - { - context.Intents.Add(new TypeIntent(SchemaValueType.String)); - context.Intents.Add(new FormatIntent(new("date-time"))); - } + /// + /// Gets the to render + /// + public JsonSchema Schema { get; } -} \ No newline at end of file +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerDefinitionViewModel.cs index 120d6b9..494b19a 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerDefinitionViewModel.cs @@ -16,21 +16,14 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; /// /// Holds the data used to render a view /// -public record V3ServerDefinitionViewModel - : V3AsyncApiDocumentViewModel +/// The that defines the to render +/// The path to the to render +/// The The name of the to render +/// The to render +public record V3ServerDefinitionViewModel(V3AsyncApiDocument Document, string Path, string Name, V3ServerDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) { - /// - public V3ServerDefinitionViewModel(V3AsyncApiDocument document, string key, V3ServerDefinition server) : base(document) { Key = key; Server = server; } - /// - /// Gets the key of the to render - /// - public string Key { get; } - - /// - /// Gets the to render - /// - public V3ServerDefinition Server { get; } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml index cd30906..f819bc8 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml @@ -20,7 +20,7 @@ @ViewBag.Title - Neuroglia AsyncAPI UI - + diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml index f7f8149..6ab3c0f 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2AsyncApi.cshtml @@ -116,7 +116,7 @@
    - +
    index++; @@ -180,7 +180,7 @@
    - +
    index++; diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_CorrelationId.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2CorrelationId.cshtml similarity index 93% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_CorrelationId.cshtml rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2CorrelationId.cshtml index bde82b7..fc31bc2 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_CorrelationId.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2CorrelationId.cshtml @@ -1,4 +1,4 @@ -@model CorrelationIdDefinitionViewModel +@model V2CorrelationIdDefinitionViewModel @{ var correlationId = this.Model.CorrelationId; } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Message.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Message.cshtml index 2365ff2..262803f 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Message.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Message.cshtml @@ -74,7 +74,7 @@
    - +
    } @@ -100,7 +100,7 @@
    - +
    @{ diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Schema.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Schema.cshtml similarity index 99% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Schema.cshtml rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Schema.cshtml index 0406ff2..d91e57c 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Schema.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Schema.cshtml @@ -1,6 +1,6 @@ @using Json.Pointer @using System.Text.Json -@model SchemaViewModel +@model V2SchemaViewModel @{ var schema = this.Model.Schema; var schemaJson = Neuroglia.Serialization.Json.JsonSerializer.Default.SerializeToElement(schema)!; diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Server.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Server.cshtml index 0cf3931..1d559d9 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Server.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v2/_V2Server.cshtml @@ -75,7 +75,7 @@
    @if (server.Bindings == null || !server.Bindings.AsEnumerable().Any()) { -

    No bindings defined.

    +

    No bindings defined.

    } else { diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml index bc78ba4..edd4539 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3AsyncApi.cshtml @@ -55,11 +55,15 @@
    - @if (document.Servers != null) + @if (document.Servers == null) + { +

    No servers defined.

    + } + else { foreach (var server in document.Servers) { - + } }
    @@ -73,11 +77,15 @@
    - @if (document.Channels != null) + @if (document.Channels == null) + { +

    No channels defined.

    + } + else { foreach (var channel in document.Channels) { - + } }
    @@ -91,7 +99,11 @@
    - @if (document.Servers != null) + @if (document.Operations == null) + { +

    No operations defined.

    + } + else { foreach (var operation in document.Operations) { @@ -101,4 +113,23 @@
    +
    + +
    + @if (document.Components == null) + { +

    No components defined.

    + } + else + { + + } +
    +
    + \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Binding.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Binding.cshtml index 68b7ef0..6820912 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Binding.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Binding.cshtml @@ -37,7 +37,7 @@ } else { -

    No specific configuration.

    +

    No specific configuration.

    } } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3BindingCollection.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3BindingCollection.cshtml new file mode 100644 index 0000000..268e968 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3BindingCollection.cshtml @@ -0,0 +1,23 @@ +@model V3BindingDefinitionCollectionViewModel +@{ + var bindings = this.Model.BindingCollection; +} + +
    + +
    +
    +
    + @foreach (var binding in bindings.AsEnumerable()) + { + + } +
    +
    +
    +
    \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml index 7d3afae..bbc2fe2 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Channel.cshtml @@ -1,16 +1,17 @@ @model V3ChannelDefinitionViewModel @{ - var channel = Model.Channel; + var channel = Model.Definition; }
    -
    -
    +
    @if (!string.IsNullOrWhiteSpace(channel.Description)) { @Html.Raw(Markdown.ToHtml(channel.Description)) } + @if (channel.Parameters != null) + { +
    + +
    + + Parameters +
    +
    +
    + + + @foreach (var parameterKvp in channel.Parameters) + { + + + + + } + +
    + @parameterKvp.Key + + @Html.Raw(Markdown.ToHtml(parameterKvp.Value.Description ?? string.Empty)) + @if (parameterKvp.Value.Enum != null && parameterKvp.Value.Enum.Count > 0) + { + Supported values: @Html.Raw(string.Join(", ", parameterKvp.Value.Enum.Select(v => $"{v}"))) + } +
    +
    +
    + } +
    - +
    + + + @foreach (var serverKvp in channel.Servers.ToDictionary(s => s.Reference, s => Model.Document.DereferenceServer(s.Reference))) + { + + + + + } + +
    + @serverKvp.Key.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[^1] + + @Html.Raw(Markdown.ToHtml(serverKvp.Value.Description ?? string.Empty)) +
    +
    +
    + +
    + +
    + + + @foreach (var operationKvp in Model.Document.GetOperationsFor($"{Model.Path}{Model.Name}")) + { + + + + + } + +
    + @operationKvp.Key.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[^1] + + @Html.Raw(Markdown.ToHtml(operationKvp.Value.Description ?? string.Empty)) +
    +
    +
    + +
    + -
    +
    @if (channel.Bindings == null || !channel.Bindings.AsEnumerable().Any()) { -

    No bindings defined.

    +

    No bindings defined.

    } else { @foreach (var binding in channel.Bindings.AsEnumerable()) { - + } }
    -
    +
    \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Components.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Components.cshtml new file mode 100644 index 0000000..04cfeb2 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Components.cshtml @@ -0,0 +1,350 @@ +@model V3ComponentsViewModel +@inject Neuroglia.AsyncApi.Generation.IJsonSchemaExampleGenerator ExampleGenerator +@{ + var components = Model.Document.Components!; +} +
    + + @if (components.Schemas != null) + { +
    + +
    + @foreach(var schemaKvp in components.Schemas) + { + + } +
    +
    + } + + @if(components.Servers != null) + { +
    + +
    + @foreach (var server in components.Servers) + { + + } +
    +
    + } + + @if (components.Channels != null) + { +
    + +
    + @foreach (var channel in components.Channels) + { + + } +
    +
    + } + + @if (components.Operations != null) + { +
    + +
    + @foreach (var operation in components.Operations) + { + + } +
    +
    + } + + @if (components.Messages != null) + { +
    + +
    + @foreach (var message in components.Messages) + { + + } +
    +
    + } + + @* @if (components.SecuritySchemes != null) + { +
    + +
    + @foreach (var scheme in components.SecuritySchemes) + { + + } +
    +
    + } + + @if (components.ServerVariables != null) + { +
    + +
    + @foreach (var variable in components.ServerVariables) + { + + } +
    +
    + } + + @if (components.Parameters != null) + { +
    + +
    + @foreach (var parameter in components.Parameters) + { + + } +
    +
    + } + + @if (components.CorrelationIds != null) + { +
    + +
    + @foreach (var correlationId in components.CorrelationIds) + { + + } +
    +
    + } + + @if (components.Replies != null) + { +
    + +
    + @foreach (var reply in components.Replies) + { + + } +
    +
    + } + + @if (components.ReplyAddresses != null) + { +
    + +
    + @foreach (var replyAddress in components.ReplyAddresses) + { + + } +
    +
    + } + + @if (components.ExternalDocs != null) + { +
    + +
    + @foreach (var externalDoc in components.ExternalDocs) + { + + } +
    +
    + } + + @if (components.Tags != null) + { +
    + +
    + @foreach (var tag in components.Tags) + { + + } +
    +
    + } + + @if (components.OperationTraits != null) + { +
    + +
    + @foreach (var trait in components.OperationTraits) + { + + } +
    +
    + } + + @if (components.MessageTraits != null) + { +
    + +
    + @foreach (var trait in components.MessageTraits) + { + + } +
    +
    + } *@ + + @if (components.ServerBindings != null) + { +
    + +
    + @foreach (var binding in components.ServerBindings) + { + + } +
    +
    + } + + @if (components.ChannelBindings != null) + { +
    + +
    + @foreach (var binding in components.ChannelBindings) + { + + } +
    +
    + } + + @if (components.OperationBindings != null) + { +
    + +
    + @foreach (var binding in components.OperationBindings) + { + + } +
    +
    + } + + @if (components.MessageBindings != null) + { +
    + +
    + @foreach (var binding in components.MessageBindings) + { + + } +
    +
    + } + +
    \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3CorrelationId.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3CorrelationId.cshtml new file mode 100644 index 0000000..67e3a4e --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3CorrelationId.cshtml @@ -0,0 +1,21 @@ +@model V3CorrelationIdDefinitionViewModel +@{ + var correlationId = this.Model.CorrelationId; +} + +
    + + @if (!string.IsNullOrWhiteSpace(correlationId.Description)) + { +

    @correlationId.Description

    + } + +
    +
    + Location + +
    +
    @correlationId.Location
    +
    + +
    \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3JsonSchema.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3JsonSchema.cshtml new file mode 100644 index 0000000..64036f3 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3JsonSchema.cshtml @@ -0,0 +1,75 @@ +@using Json.Pointer +@using System.Text.Json +@model V3JsonSchemaViewModel +@{ + var schema = this.Model.Schema; + var schemaJson = Neuroglia.Serialization.Json.JsonSerializer.Default.SerializeToElement(schema)!; + var jsonType = schema.GetJsonType(); + var properties = schema.GetProperties(); + if ((properties == null || !properties.Any()) && (properties == null || !properties.Any())) return; + var required = schema.GetRequired(); +} +@switch (jsonType) +{ + case SchemaValueType.Object: + + + @foreach (var property in properties) + { + var propertyType = property.Value.GetJsonType(); + var nullable = (propertyType & SchemaValueType.Null) == SchemaValueType.Null; + propertyType = propertyType & ~SchemaValueType.Null; + var propertyTypeName = propertyType.HasValue ? EnumHelper.Stringify(propertyType.Value).ToLowerInvariant() : "object"; + var typeDescription = string.Empty; + var typeFlags = propertyType.HasValue ? EnumHelper.GetFlags(propertyType.Value) : Array.Empty(); + if (propertyType.HasValue && typeFlags.Count() > 1) + { + propertyTypeName = "oneOf"; + typeDescription = string.Join("\n", typeFlags.Select(t => EnumHelper.Stringify(t).ToLowerInvariant())); + } + var constValue = property.Value.GetConst(); + var format = property.Value.GetFormat(); + var pattern = property.Value.GetPattern(); + var enumValue = property.Value.GetEnum(); + var description = property.Value.GetDescription(); + + + + + + } + +
    + @property.Key + + @propertyTypeName + @if (required?.Contains(property.Key) == true) + { + required + } + @if (nullable) + { + nullable + } + @if (constValue != null) + { + const + } + @if (format != null) + { + format + } + @if (pattern != null) + { + pattern + } + @if (enumValue != null) + { + v == null ? "null" : v.GetValue())))" role="button">enum + } + + @description +
    + break; + default: break; +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Message.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Message.cshtml new file mode 100644 index 0000000..31b49ed --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Message.cshtml @@ -0,0 +1,88 @@ +@model V3MessageDefinitionViewModel +@inject Neuroglia.Serialization.IJsonSerializer JsonSerializer +@inject Neuroglia.AsyncApi.Generation.IJsonSchemaExampleGenerator ExampleGenerator +@{ + var message = Model.Message; +} + +
    + +
    + + @if (!string.IsNullOrWhiteSpace(message.Description)) + { + @Html.Raw(Markdown.ToHtml(message.Description)) + } + + @if (message.CorrelationId != null) + { + + } + + @if (message.Payload == null) + { +

    The message does not specify a payload schema.

    + } + else + { + var schemaDefinition = string.IsNullOrWhiteSpace(message.Payload.Reference) ? message.Payload : Model.Document.DereferenceSchema(message.Payload.Reference); + + } + +
    + +
    + @if (message.Bindings == null || !message.Bindings.AsEnumerable().Any()) + { +

    No bindings defined.

    + } + else + { + @foreach (var binding in message.Bindings.AsEnumerable()) + { + + } + } +
    +
    + +
    +
    \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml index 164bb96..e6c8091 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml @@ -1,20 +1,19 @@ @model V3OperationDefinitionViewModel @{ - var operation = Model.Operation; + var operation = Model.Definition; var badgeColor = operation.Action == V3OperationAction.Send ? "info" : "info"; var badgeTooltip = operation.Action == V3OperationAction.Send ? "An operation used to publish a message to the specified channel." : "An operation used to subscribe to messages from the specified channel."; var badgeText = operation.Action == V3OperationAction.Send ? "send" : "receive"; }
    - -
    - -
    - +
    @if (!string.IsNullOrWhiteSpace(operation.Description)) { @Html.Raw(Markdown.ToHtml(operation.Description)) }
    - +
    + @if (operation.Messages == null) + { +

    No messages have been defined for the operation.

    + } + else + { + int index = 1; + foreach (var messageKvp in operation.Messages.ToDictionary(m => m.Reference, m => Model.Document.DereferenceMessage(m.Reference))) + { + + index++; + } + } +
    +
    + +
    + -
    +
    @if (operation.Bindings == null || !operation.Bindings.AsEnumerable().Any()) { -

    No bindings defined.

    +

    No bindings defined.

    } else { @foreach (var binding in operation.Bindings.AsEnumerable()) { - + } }
    -
    +
    \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3OperationMessage.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3OperationMessage.cshtml new file mode 100644 index 0000000..38a7257 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3OperationMessage.cshtml @@ -0,0 +1,86 @@ +@model V3OperationMessageDefinitionViewModel +@{ + var message = Model.Message; +} + +
    + +
    + + @if (!string.IsNullOrWhiteSpace(message.Description)) + { + @Html.Raw(Markdown.ToHtml(message.Description)) + } + + @if (message.CorrelationId != null) + { + + } + + @if (message.Payload == null) + { +

    The message does not specify a payload schema.

    + } + else + { + var schemaDefinition = string.IsNullOrWhiteSpace(message.Payload.Reference) ? message.Payload : Model.Document.DereferenceSchema(message.Payload.Reference); + + } +
    + +
    + @if (message.Bindings == null || !message.Bindings.AsEnumerable().Any()) + { +

    No bindings defined.

    + } + else + { + @foreach (var binding in message.Bindings.AsEnumerable()) + { + + } + } +
    +
    + +
    +
    \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Schema.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Schema.cshtml new file mode 100644 index 0000000..a09dd17 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Schema.cshtml @@ -0,0 +1,45 @@ +@model V3SchemaViewModel +@inject Neuroglia.Serialization.IJsonSerializer JsonSerializer +@inject Neuroglia.AsyncApi.Generation.IJsonSchemaExampleGenerator ExampleGenerator +@{ + var schemaFormat = Model.SchemaDefinition.SchemaFormat?.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[0] ?? "application/schema+json"; + switch (schemaFormat) + { + case "application/schema+json": + var schema = Model.SchemaDefinition.Schema is JsonSchema jsonSchema ? jsonSchema : JsonSerializer.Deserialize(JsonSerializer.SerializeToText(Model.SchemaDefinition))!; + var type = schema.GetJsonType()!; + var properties = schema.GetProperties(); + var examples = Model.Examples; +
    + + @if (type == SchemaValueType.Array || type == SchemaValueType.Object) + { +
    +
    +
    + +
    +
    + @{ + var example = examples != null && examples.Any() ? examples.Last().Payload : ExampleGenerator.GenerateExample(schema); + var serializationOptions = new System.Text.Json.JsonSerializerOptions(); + Neuroglia.Serialization.Json.JsonSerializer.DefaultOptionsConfiguration(serializationOptions); + serializationOptions.WriteIndented = true; +
    @System.Text.Json.JsonSerializer.Serialize(example, serializationOptions)
    + } +
    +
    +
    + } +
    + break; + default: + + break; + } +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Server.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Server.cshtml index ec365b6..5d13be5 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Server.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Server.cshtml @@ -1,38 +1,38 @@ @model V3ServerDefinitionViewModel @{ - var server = this.Model.Server; + var server = this.Model.Definition; var serverAddress = $"{server.Host}{server.PathName}"; }
    - -
    +
    @if (!string.IsNullOrWhiteSpace(server.Description)) { -

    @Html.Raw(Markdown.ToHtml(server.Description ?? string.Empty))

    + @Html.Raw(Markdown.ToHtml(server.Description ?? string.Empty)) } @if (server.Variables != null) {
    - +
    Variables
    -
    +
    @foreach (var variableKvp in server.Variables) @@ -55,16 +55,43 @@ } + +
    + + @foreach (var channelKvp in Model.Document.GetChannelsFor($"{Model.Path}{Model.Name}")) + { + + + + + } + +
    + @channelKvp.Key.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[^1] + + @Html.Raw(Markdown.ToHtml(channelKvp.Value.Description ?? string.Empty)) +
    +
    +
    + @if (server.Security != null) {
    - -
    +
    @foreach (var securityRequirement in server.Security) { @* *@ @@ -76,21 +103,21 @@ {
    -
    +
    @if (server.Bindings == null || !server.Bindings.AsEnumerable().Any()) { -

    No bindings defined.

    +

    No bindings defined.

    } else { @foreach (var binding in server.Bindings.AsEnumerable()) { - + } }
    diff --git a/src/Neuroglia.AsyncApi.Core/Bindings/BindingDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/Bindings/BindingDefinitionCollection.cs index d733811..fcedf09 100644 --- a/src/Neuroglia.AsyncApi.Core/Bindings/BindingDefinitionCollection.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/BindingDefinitionCollection.cs @@ -54,4 +54,6 @@ public virtual void Add(TBinding binding) /// A new containing the s the is made out of public abstract IEnumerable AsEnumerable(); + IEnumerable IBindingDefinitionCollection.AsEnumerable() => this.AsEnumerable().Cast(); + } diff --git a/src/Neuroglia.AsyncApi.Core/Bindings/IBindingDefinitionCollection.cs b/src/Neuroglia.AsyncApi.Core/Bindings/IBindingDefinitionCollection.cs index 63c1d4a..7d82802 100644 --- a/src/Neuroglia.AsyncApi.Core/Bindings/IBindingDefinitionCollection.cs +++ b/src/Neuroglia.AsyncApi.Core/Bindings/IBindingDefinitionCollection.cs @@ -13,15 +13,34 @@ namespace Neuroglia.AsyncApi.Bindings; +/// +/// Defines the fundamentals of a collection of s +/// +public interface IBindingDefinitionCollection + : IReferenceable +{ + + /// + /// Converts the into a new containing the s the is made out of + /// + /// A new containing the s the is made out of + IEnumerable AsEnumerable(); + +} + /// /// Defines the fundamentals of a collection of s /// /// The type of contained by the public interface IBindingDefinitionCollection - : IReferenceable + : IBindingDefinitionCollection where TBinding : IBindingDefinition { - + /// + /// Converts the into a new containing the s the is made out of + /// + /// A new containing the s the is made out of + new IEnumerable AsEnumerable(); } diff --git a/src/Neuroglia.AsyncApi.Core/v3/Attributes/AsyncApiV3Attribute.cs b/src/Neuroglia.AsyncApi.Core/v3/Attributes/AsyncApiV3Attribute.cs index 27365f9..2cb862d 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/Attributes/AsyncApiV3Attribute.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/Attributes/AsyncApiV3Attribute.cs @@ -23,4 +23,9 @@ public class AsyncApiV3Attribute(string title, string version) : AsyncApiAttribute(title, version) { + /// + /// Gets/sets references to the tags to mark the with + /// + public string[]? Tags { get; set; } + } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelParameterV3Attribute.cs b/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelParameterV3Attribute.cs index 063c02a..6d66e77 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelParameterV3Attribute.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelParameterV3Attribute.cs @@ -53,4 +53,9 @@ public class ChannelParameterV3Attribute(string channel, string name) ///
    public string? Location { get; init; } + /// + /// Gets/sets the 's examples, if any + /// + public string[]? Examples { get; init; } + } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelV3Attribute.cs b/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelV3Attribute.cs index 24616fe..1ff9259 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelV3Attribute.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/Attributes/ChannelV3Attribute.cs @@ -30,7 +30,7 @@ public class ChannelV3Attribute(string name) /// /// Gets/sets the 's address /// - public string? Address { get; init; } + public string Address { get; init; } = "unknown"; /// /// Gets/sets the 's title @@ -57,9 +57,19 @@ public class ChannelV3Attribute(string name) /// public string[]? Servers { get; init; } + /// + /// Gets/sets a reference to the channel's bindings, if any + /// + public string? Bindings { get; set; } + /// /// Gets/sets the url at which to get the 's external documentation, if any /// public virtual Uri? ExternalDocumentationUrl { get; init; } + /// + /// Gets/sets references to the tags to mark the with + /// + public string[]? Tags { get; set; } + } diff --git a/src/Neuroglia.AsyncApi.Core/v3/Attributes/MessageV3Attribute.cs b/src/Neuroglia.AsyncApi.Core/v3/Attributes/MessageV3Attribute.cs index 821287b..d3edcef 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/Attributes/MessageV3Attribute.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/Attributes/MessageV3Attribute.cs @@ -24,31 +24,51 @@ public class MessageV3Attribute /// /// Gets/sets the 's name /// - public virtual string? Name { get; set; } + public string? Name { get; set; } /// /// Gets/sets the 's title /// - public virtual string? Title { get; set; } + public string? Title { get; set; } /// /// Gets/sets the 's description /// - public virtual string? Description { get; set; } + public string? Description { get; set; } /// /// Gets/sets the 's summary /// - public virtual string? Summary { get; set; } + public string? Summary { get; set; } /// /// Gets/sets the 's content type /// - public virtual string? ContentType { get; set; } + public string? ContentType { get; set; } + + /// + /// Gets/sets a reference to the message's bindings, if any + /// + public string? Bindings { get; set; } + + /// + /// Gets/sets a reference to the message's payload schema, if any + /// + public string? PayloadSchema { get; init; } + + /// + /// Gets/sets a reference to the message's headers schema, if any + /// + public string? HeadersSchema { get; init; } /// /// Gets/sets the url at which to get the 's external documentation, if any /// - public virtual Uri? ExternalDocumentationUrl { get; init; } + public Uri? ExternalDocumentationUrl { get; init; } + + /// + /// Gets/sets references to the tags to mark the with + /// + public string[]? Tags { get; set; } } diff --git a/src/Neuroglia.AsyncApi.Core/v3/Attributes/OperationV3Attribute.cs b/src/Neuroglia.AsyncApi.Core/v3/Attributes/OperationV3Attribute.cs index ec9ee38..f8a2a8d 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/Attributes/OperationV3Attribute.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/Attributes/OperationV3Attribute.cs @@ -42,21 +42,46 @@ public class OperationV3Attribute(string name, V3OperationAction action, string /// /// Gets/sets the 's title /// - public virtual string? Title { get; init; } + public string? Title { get; init; } /// /// Gets/sets the 's summary /// - public virtual string? Summary { get; init; } + public string? Summary { get; init; } /// /// Gets/sets the 's summary /// - public virtual string? Description { get; init; } + public string? Description { get; init; } + + /// + /// Gets/sets a reference to the operation's bindings, if any + /// + public string? Bindings { get; set; } /// /// Gets/sets the url at which to get the 's external documentation, if any /// - public virtual Uri? ExternalDocumentationUrl { get; init; } + public Uri? ExternalDocumentationUrl { get; init; } + + /// + /// Gets/sets references to the tags to mark the with + /// + public string[]? Tags { get; set; } + + /// + /// Gets/sets a reference to the operation's . Ignored if either or have been set. + /// + public string? Message { get; init; } + + /// + /// Gets/sets the type of the 's message payload. Ignored if has been set. + /// + public Type? MessagePayloadType { get; init; } + + /// + /// Gets/sets the type of the 's message headers. Ignored if has been set. + /// + public Type? HeadersPayloadType { get; init; } } diff --git a/src/Neuroglia.AsyncApi.Core/v3/Extensions/V3AsyncApiDocumentExtensions.cs b/src/Neuroglia.AsyncApi.Core/v3/Extensions/V3AsyncApiDocumentExtensions.cs index 48be889..73d2192 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/Extensions/V3AsyncApiDocumentExtensions.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/Extensions/V3AsyncApiDocumentExtensions.cs @@ -19,6 +19,33 @@ namespace Neuroglia.AsyncApi.v3; public static class V3AsyncApiDocumentExtensions { + /// + /// Gets all the s defined by the specified + /// + /// The extended + /// A reference to the to get the s for + /// A new containing all the s defined by the specified + public static IEnumerable> GetChannelsFor(this V3AsyncApiDocument document, string serverReference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(serverReference); + foreach(var channelKvp in document.Channels.Where(c => c.Value.Servers.Any(s => s.Reference == serverReference))) yield return channelKvp; + if (document.Components?.Channels != null) foreach (var channelKvp in document.Components.Channels.Where(c => c.Value.Servers.Any(s => s.Reference == serverReference))) yield return channelKvp; + + } + + /// + /// Gets all the s defined by the specified + /// + /// The extended + /// A reference to the to get the s for + /// A new containing all the s defined by the specified + public static IEnumerable> GetOperationsFor(this V3AsyncApiDocument document, string channelReference) + { + ArgumentException.ThrowIfNullOrWhiteSpace(channelReference); + foreach (var operationKvp in document.Operations.Where(o => o.Value.Channel.Reference == channelReference)) yield return operationKvp; + if (document.Components?.Operations != null) foreach (var operationKvp in document.Components.Operations.Where(o => o.Value.Channel.Reference == channelReference)) yield return operationKvp; + } + /// /// Dereferences the specified component /// diff --git a/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs b/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs index 3e8eb17..d8339ec 100644 --- a/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs +++ b/src/Neuroglia.AsyncApi.Core/v3/V3ChannelDefinition.cs @@ -28,7 +28,7 @@ public record V3ChannelDefinition /// It MAY contain Channel Address Expressions. Query parameters and fragments SHALL NOT be used, instead use bindings to define them. ///
    [DataMember(Order = 1, Name = "address"), JsonPropertyOrder(1), JsonPropertyName("address"), YamlMember(Order = 1, Alias = "address", ScalarStyle = ScalarStyle.SingleQuoted)] - public virtual string? Address { get; set; } + public virtual string Address { get; set; } = "unknown"; /// /// Gets/sets a map of the messages that will be sent to this channel by any application at any time. Every message sent to this channel MUST be valid against one, and only one, of the message objects defined in this map. diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs index 1478f6e..56df84c 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ChannelDefinitionBuilder.cs @@ -25,7 +25,7 @@ public interface IV3ChannelDefinitionBuilder /// /// The address to use /// The configured - IV3ChannelDefinitionBuilder WithAddress(string? address); + IV3ChannelDefinitionBuilder WithAddress(string address); /// /// Configures the to use the specified diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ParameterDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ParameterDefinitionBuilder.cs index 830b170..b702ad2 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ParameterDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3ParameterDefinitionBuilder.cs @@ -53,7 +53,7 @@ public interface IV3ParameterDefinitionBuilder /// /// The location to use /// The configured - IV3ParameterDefinitionBuilder WithLocation(string location); + IV3ParameterDefinitionBuilder WithLocation(string? location); /// /// Builds the configured diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3SchemaDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3SchemaDefinitionBuilder.cs index 62b080c..e345aba 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3SchemaDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/Interfaces/IV3SchemaDefinitionBuilder.cs @@ -27,6 +27,12 @@ public interface IV3SchemaDefinitionBuilder /// The configured IV3SchemaDefinitionBuilder WithSchema(object schema); + /// + /// Configures the to use the specified + /// + /// An used to setup the to use + void WithJsonSchema(Action setup); + /// /// Configures the to use the specified format /// diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs index 662c583..b8ddbc9 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ChannelDefinitionBuilder.cs @@ -45,8 +45,9 @@ public virtual void Use(string reference) } /// - public virtual IV3ChannelDefinitionBuilder WithAddress(string? address) + public virtual IV3ChannelDefinitionBuilder WithAddress(string address) { + ArgumentException.ThrowIfNullOrWhiteSpace(address); Channel.Address = address; return this; } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ParameterDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ParameterDefinitionBuilder.cs index 928acf5..96b43f4 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ParameterDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3ParameterDefinitionBuilder.cs @@ -75,9 +75,8 @@ public virtual IV3ParameterDefinitionBuilder WithExample(string example) } /// - public virtual IV3ParameterDefinitionBuilder WithLocation(string location) + public virtual IV3ParameterDefinitionBuilder WithLocation(string? location) { - ArgumentException.ThrowIfNullOrWhiteSpace(location); Parameter.Location = location; return this; } diff --git a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SchemaDefinitionBuilder.cs b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SchemaDefinitionBuilder.cs index 5330b90..6e6ec62 100644 --- a/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SchemaDefinitionBuilder.cs +++ b/src/Neuroglia.AsyncApi.FluentBuilders/v3/V3SchemaDefinitionBuilder.cs @@ -44,6 +44,16 @@ public virtual void Use(string reference) Schema.Reference = reference; } + /// + public virtual void WithJsonSchema(Action setup) + { + ArgumentNullException.ThrowIfNull(setup); + var builder = new JsonSchemaBuilder(); + setup(builder); + Schema.SchemaFormat = "application/schema+json"; + Schema.Schema = builder.Build(); + } + /// public virtual IV3SchemaDefinitionBuilder WithFormat(string format) { diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v2.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v2.cs index 9fde73e..62a49ed 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v2.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v2.cs @@ -112,7 +112,7 @@ protected virtual void ConfigureV2OperationMessageFor(IV2MessageDefinitionBuilde if (parameters.Length == 1 || parameters.Length == 2 && parameters[1].ParameterType == typeof(CancellationToken)) { messageType = parameters.First().ParameterType; - messageSchema = new JsonSchemaBuilder().FromType(parameters.First().ParameterType, JsonSchemaGeneratorConfiguration.Default); + messageSchema = new JsonSchemaBuilder().FromType(parameters.First().ParameterType, Data.Schemas.Json.JsonSchemaGeneratorConfiguration.Default); } else { @@ -123,7 +123,7 @@ protected virtual void ConfigureV2OperationMessageFor(IV2MessageDefinitionBuilde foreach (var parameter in parameters) { if (parameter.TryGetCustomAttribute(out _)) continue; - var parameterSchema = messageSchemaBuilder.FromType(parameter.ParameterType, JsonSchemaGeneratorConfiguration.Default); + var parameterSchema = messageSchemaBuilder.FromType(parameter.ParameterType, Data.Schemas.Json.JsonSchemaGeneratorConfiguration.Default); messageSchemaProperties.Add(parameter.Name!, parameterSchema); if (parameter.TryGetCustomAttribute(out _) || !parameter.ParameterType.IsNullable() || parameter.DefaultValue == DBNull.Value) requiredProperties.Add(parameter.Name!); } @@ -132,7 +132,7 @@ protected virtual void ConfigureV2OperationMessageFor(IV2MessageDefinitionBuilde messageSchema = messageSchemaBuilder.Build(); } } - else messageSchema = new JsonSchemaBuilder().FromType(messageType, JsonSchemaGeneratorConfiguration.Default); + else messageSchema = new JsonSchemaBuilder().FromType(messageType, Data.Schemas.Json.JsonSchemaGeneratorConfiguration.Default); messageBuilder.WithPayloadSchema(messageSchema); var message = operationMethod.GetCustomAttribute(); message ??= messageType?.GetCustomAttribute(); diff --git a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v3.cs b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v3.cs index c933f3d..6da9df1 100644 --- a/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v3.cs +++ b/src/Neuroglia.AsyncApi.Generation/AsyncApiDocumentGenerator.v3.cs @@ -11,6 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Neuroglia.Data.Schemas.Json; + namespace Neuroglia.AsyncApi.Generation; public partial class AsyncApiDocumentGenerator @@ -27,38 +29,47 @@ protected virtual async Task GenerateV3DocumentForAsync(Type { ArgumentNullException.ThrowIfNull(type); ArgumentNullException.ThrowIfNull(options); - var asyncApi = type.GetCustomAttribute() ?? throw new ArgumentException($"The specified type '{type.Name}' is not marked with the {nameof(AsyncApiV3Attribute)}", nameof(type)); - var builder = this.ServiceProvider.GetRequiredService(); - options.V3BuilderSetup?.Invoke(builder); - builder - .WithId(asyncApi.Id!) - .WithTitle(asyncApi.Title) - .WithVersion(asyncApi.Version); - if (!string.IsNullOrWhiteSpace(asyncApi.Description)) builder.WithDescription(asyncApi.Description); - if (!string.IsNullOrWhiteSpace(asyncApi.LicenseName) && !string.IsNullOrWhiteSpace(asyncApi.LicenseUrl)) builder.WithLicense(asyncApi.LicenseName, new Uri(asyncApi.LicenseUrl, UriKind.RelativeOrAbsolute)); - if (!string.IsNullOrWhiteSpace(asyncApi.TermsOfServiceUrl)) builder.WithTermsOfService(new Uri(asyncApi.TermsOfServiceUrl, UriKind.RelativeOrAbsolute)); - if (!string.IsNullOrWhiteSpace(asyncApi.ContactName)) builder.WithContact(asyncApi.ContactName, string.IsNullOrWhiteSpace(asyncApi.ContactUrl) ? null : new Uri(asyncApi.ContactUrl, UriKind.RelativeOrAbsolute), asyncApi.ContactEmail); - foreach(var channel in type.GetCustomAttributes()) + var asyncApiAttribute = type.GetCustomAttribute() ?? throw new ArgumentException($"The specified type '{type.Name}' is not marked with the {nameof(AsyncApiV3Attribute)}", nameof(type)); + var document = this.ServiceProvider.GetRequiredService(); + options.V3BuilderSetup?.Invoke(document); + document + .WithId(asyncApiAttribute.Id!) + .WithTitle(asyncApiAttribute.Title) + .WithVersion(asyncApiAttribute.Version); + if (!string.IsNullOrWhiteSpace(asyncApiAttribute.Description)) document.WithDescription(asyncApiAttribute.Description); + if (!string.IsNullOrWhiteSpace(asyncApiAttribute.LicenseName) && !string.IsNullOrWhiteSpace(asyncApiAttribute.LicenseUrl)) document.WithLicense(asyncApiAttribute.LicenseName, new Uri(asyncApiAttribute.LicenseUrl, UriKind.RelativeOrAbsolute)); + if (!string.IsNullOrWhiteSpace(asyncApiAttribute.TermsOfServiceUrl)) document.WithTermsOfService(new Uri(asyncApiAttribute.TermsOfServiceUrl, UriKind.RelativeOrAbsolute)); + if (!string.IsNullOrWhiteSpace(asyncApiAttribute.ContactName)) document.WithContact(asyncApiAttribute.ContactName, string.IsNullOrWhiteSpace(asyncApiAttribute.ContactUrl) ? null : new Uri(asyncApiAttribute.ContactUrl, UriKind.RelativeOrAbsolute), asyncApiAttribute.ContactEmail); + if (asyncApiAttribute.Tags != null) { - await this.GenerateV3ChannelForAsync(builder, channel, options, cancellationToken); + foreach (var tagReference in asyncApiAttribute.Tags) + { + document.WithTag(tag => tag.Use(tagReference)); + } + } + var channelParameters = type.GetCustomAttributes(); + foreach (var channel in type.GetCustomAttributes()) + { + await this.GenerateV3ChannelForAsync(document, channel, channelParameters.Where(c => c.Channel == channel.Name), options, cancellationToken); } foreach (var method in type.GetMethods(BindingFlags.Default | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy).Where(m => m.GetCustomAttribute() != null)) { var operation = method.GetCustomAttribute()!; - await this.GenerateV3OperationForAsync(builder, operation, method, options, cancellationToken); + await this.GenerateV3OperationForAsync(document, operation, method, options, cancellationToken); } - return builder.Build(); + return document.Build(); } /// /// Builds a new /// /// The to configure - /// The attribute used to describe the to configure + /// The attribute used to describe the to build + /// An containing the s that apply to the to build /// The to use /// A /// A new awaitable - protected virtual Task GenerateV3ChannelForAsync(IV3AsyncApiDocumentBuilder document, ChannelV3Attribute channelAttribute, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) + protected virtual Task GenerateV3ChannelForAsync(IV3AsyncApiDocumentBuilder document, ChannelV3Attribute channelAttribute, IEnumerable? channelParameterAttributes, AsyncApiDocumentGenerationOptions options, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(document); ArgumentNullException.ThrowIfNull(channelAttribute); @@ -77,10 +88,42 @@ protected virtual Task GenerateV3ChannelForAsync(IV3AsyncApiDocumentBuilder docu channel.WithServer(server); } } - if (channelAttribute?.ExternalDocumentationUrl != null) + if (channelParameterAttributes != null) + { + foreach (var parameterAttribute in channelParameterAttributes) + { + channel.WithParameter(parameterAttribute.Name, parameter => + { + parameter + .WithDefaultValue(parameterAttribute.Default) + .WithEnumValues(parameterAttribute.Enum) + .WithDescription(parameterAttribute.Description) + .WithLocation(parameterAttribute.Location); + if (parameterAttribute.Examples != null) + { + foreach(var example in parameterAttribute.Examples) + { + parameter.WithExample(example); + } + } + }); + } + } + if (!string.IsNullOrEmpty(channelAttribute.Bindings)) + { + channel.WithBindings(bindings => bindings.Use(channelAttribute.Bindings)); + } + if (channelAttribute.ExternalDocumentationUrl != null) { channel.WithExternalDocumentation(doc => doc.WithUrl(channelAttribute.ExternalDocumentationUrl)); } + if (channelAttribute.Tags != null) + { + foreach(var tagReference in channelAttribute.Tags) + { + channel.WithTag(tag => tag.Use(tagReference)); + } + } }); return Task.CompletedTask; } @@ -101,40 +144,45 @@ protected virtual Task GenerateV3OperationForAsync(IV3AsyncApiDocumentBuilder do ArgumentNullException.ThrowIfNull(operationMethod); ArgumentNullException.ThrowIfNull(options); var operationParameters = operationMethod.GetParameters().Where(p => p.ParameterType != typeof(CancellationToken)).ToList(); - var requestMessageType = operationParameters.Count == 1 ? operationParameters[0].ParameterType : null; - var requestMessageAttribute = operationMethod.GetCustomAttribute(); - JsonSchema? requestMessagePayloadSchema = null; - var schemaGeneratorConfiguration = new SchemaGeneratorConfiguration() - { - PropertyNameResolver = PropertyNameResolvers.CamelCase, - Optimize = false - }; - schemaGeneratorConfiguration.Generators.Add(new DateTimeOffsetJsonSchemaGenerator()); - schemaGeneratorConfiguration.Refiners.Add(new XmlDocumentationJsonSchemaRefiner()); - if (requestMessageType == null) + var requestMessagePayloadType = operationAttribute.MessagePayloadType; + var requestMessageAttribute = operationMethod.GetCustomAttribute() ?? requestMessagePayloadType?.GetCustomAttribute(); + var requestMessagePayloadSchema = (JsonSchema?)null; + var requestMessageHeadersSchema = operationAttribute.HeadersPayloadType == null ? null : new JsonSchemaBuilder().FromType(operationAttribute.HeadersPayloadType, Data.Schemas.Json.JsonSchemaGeneratorConfiguration.Default); + if (requestMessageAttribute == null) { - var schemaBuilder = new JsonSchemaBuilder(); - var messageSchemaProperties = new Dictionary(); - var requiredProperties = new List(); - requestMessageType = typeof(object); - foreach (var parameter in operationParameters) + if (requestMessagePayloadType == null) + { + if (operationParameters.Count == 1) + { + requestMessagePayloadType = operationParameters[0].ParameterType; + requestMessagePayloadSchema = new JsonSchemaBuilder().FromType(requestMessagePayloadType, Data.Schemas.Json.JsonSchemaGeneratorConfiguration.Default); + } + else + { + var schemaBuilder = new JsonSchemaBuilder(); + var messageSchemaProperties = new Dictionary(); + var requiredProperties = new List(); + requestMessagePayloadType = typeof(object); + foreach (var parameter in operationParameters) + { + if (parameter.TryGetCustomAttribute(out _)) continue; + var parameterSchema = schemaBuilder.FromType(parameter.ParameterType, Data.Schemas.Json.JsonSchemaGeneratorConfiguration.Default); + messageSchemaProperties.Add(parameter.Name!, parameterSchema); + if (parameter.TryGetCustomAttribute(out _) || !parameter.ParameterType.IsNullable() || parameter.DefaultValue == DBNull.Value) requiredProperties.Add(parameter.Name!); + } + schemaBuilder.Properties(messageSchemaProperties); + schemaBuilder.Required(requiredProperties); + requestMessagePayloadSchema = schemaBuilder.Build(); + } + } + else { - if (parameter.TryGetCustomAttribute(out _)) continue; - var parameterSchema = schemaBuilder.FromType(parameter.ParameterType, schemaGeneratorConfiguration); - messageSchemaProperties.Add(parameter.Name!, parameterSchema); - if (parameter.TryGetCustomAttribute(out _) || !parameter.ParameterType.IsNullable() || parameter.DefaultValue == DBNull.Value) requiredProperties.Add(parameter.Name!); + requestMessagePayloadSchema = new JsonSchemaBuilder().FromType(requestMessagePayloadType, Data.Schemas.Json.JsonSchemaGeneratorConfiguration.Default).Build(); } - schemaBuilder.Properties(messageSchemaProperties); - schemaBuilder.Required(requiredProperties); - requestMessagePayloadSchema = schemaBuilder.Build(); } - else - { - requestMessagePayloadSchema = new JsonSchemaBuilder().FromType(requestMessageType, schemaGeneratorConfiguration).Build(); - } - requestMessageAttribute ??= requestMessageType?.GetCustomAttribute(); - var requestMessageName = $"{operationAttribute.Name}-request"; - var replyMessageName = $"{operationAttribute.Name}-reply"; + var requestMessageName = $"{operationAttribute.Name}Request"; + var replyMessageName = $"{operationAttribute.Name}Reply"; + var requestMessageReference = operationAttribute.Message ?? $"#/components/messages/{requestMessageName}"; document.WithOperation(operationAttribute.Name, operation => { operation @@ -143,38 +191,79 @@ protected virtual Task GenerateV3OperationForAsync(IV3AsyncApiDocumentBuilder do .WithTitle(operationAttribute.Title) .WithSummary(operationAttribute.Summary) .WithDescription(operationAttribute.Description) - .WithMessage($"#/components/messages/{requestMessageName}"); + .WithMessage(requestMessageReference); + if (!string.IsNullOrEmpty(operationAttribute.Bindings)) + { + operation.WithBindings(bindings => bindings.Use(operationAttribute.Bindings)); + } if (operationAttribute.ExternalDocumentationUrl != null) { operation.WithExternalDocumentation(doc => doc.WithUrl(operationAttribute.ExternalDocumentationUrl)); } - foreach(var tagAttribute in operationMethod.GetCustomAttributes()) + if (operationAttribute.Tags != null) + { + foreach (var tagReference in operationAttribute.Tags) + { + operation.WithTag(tag => tag.Use(tagReference)); + } + } + foreach (var tagAttribute in operationMethod.GetCustomAttributes()) { - operation.WithTag(tag => tag + operation + .WithTag(tag => tag .WithName(tagAttribute.Name) .WithDescription(tagAttribute.Description)); } }); - document.WithMessageComponent(requestMessageName, message => + if (string.IsNullOrWhiteSpace(operationAttribute.Message)) { - message - .WithName(requestMessageAttribute?.Name) - .WithTitle(requestMessageAttribute?.Title) - .WithDescription(requestMessageAttribute?.Description) - .WithSummary(requestMessageAttribute?.Summary) - .WithDescription(requestMessageAttribute?.Description); - if (requestMessagePayloadSchema != null) + document.WithMessageComponent(requestMessageName, message => { message - .WithPayloadSchema(schema => schema - .WithFormat("application/schema+json") - .WithSchema(requestMessagePayloadSchema)); - } - if (requestMessageAttribute?.ExternalDocumentationUrl != null) - { - message.WithExternalDocumentation(doc => doc.WithUrl(requestMessageAttribute.ExternalDocumentationUrl)); - } - }); + .WithName(requestMessageAttribute?.Name) + .WithTitle(requestMessageAttribute?.Title) + .WithDescription(requestMessageAttribute?.Description) + .WithSummary(requestMessageAttribute?.Summary) + .WithDescription(requestMessageAttribute?.Description); + if (!string.IsNullOrEmpty(requestMessageAttribute?.Bindings)) + { + message.WithBindings(bindings => bindings.Use(requestMessageAttribute.Bindings)); + } + if (!string.IsNullOrWhiteSpace(requestMessageAttribute?.PayloadSchema)) + { + message.WithPayloadSchema(schema => schema.Use(requestMessageAttribute.PayloadSchema)); + } + else if (requestMessagePayloadSchema != null) + { + message + .WithPayloadSchema(schema => schema + .WithFormat("application/schema+json") + .WithSchema(requestMessagePayloadSchema)); + } + if (!string.IsNullOrWhiteSpace(requestMessageAttribute?.HeadersSchema)) + { + message.WithHeadersSchema(schema => schema.Use(requestMessageAttribute.HeadersSchema)); + } + else if (requestMessageHeadersSchema != null) + { + message + .WithHeadersSchema(schema => schema + .WithFormat("application/schema+json") + .WithSchema(requestMessageHeadersSchema)); + } + if (requestMessageAttribute?.ExternalDocumentationUrl != null) + { + message.WithExternalDocumentation(doc => doc.WithUrl(requestMessageAttribute.ExternalDocumentationUrl)); + } + if (requestMessageAttribute?.Tags != null) + { + foreach (var tagReference in requestMessageAttribute.Tags) + { + message.WithTag(tag => tag.Use(tagReference)); + } + } + }); + } return Task.CompletedTask; } diff --git a/src/Neuroglia.AsyncApi.Generation/JsonSchemaGeneratorConfiguration.cs b/src/Neuroglia.AsyncApi.Generation/JsonSchemaGeneratorConfiguration.cs new file mode 100644 index 0000000..f52c5d5 --- /dev/null +++ b/src/Neuroglia.AsyncApi.Generation/JsonSchemaGeneratorConfiguration.cs @@ -0,0 +1,57 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Neuroglia.AsyncApi.Generation; +using Neuroglia.Data.Schemas.Json; + +namespace Neuroglia.AsyncApi; + +/// +/// Exposes constants about generation +/// +public static class JsonSchemaGeneratorConfiguration +{ + + /// + /// Gets/sets an used to configure the used by default + /// + public static Action DefaultOptionsConfiguration { get; set; } = (options) => + { + options.PropertyNameResolver = PropertyNameResolvers.CamelCase; + options.Optimize = false; + options.Generators.Add(new DateTimeOffsetSchemaGenerator()); + options.Refiners.Add(new XmlDocumentationJsonSchemaRefiner()); + }; + + static SchemaGeneratorConfiguration? _default; + /// + /// Gets the default . For most use cases, please use dependency injection instead. + /// + public static SchemaGeneratorConfiguration Default + { + get + { + if (_default == null) + { + _default = new SchemaGeneratorConfiguration(); + DefaultOptionsConfiguration(_default); + } + return _default; + } + set + { + _default = value; + } + } + +} From 31028e986d689b580ad09365430a9982a6253972 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Thu, 19 Dec 2024 17:41:24 +0100 Subject: [PATCH 12/21] fix(CI/CD): Fixed pipelines to use .NET 9.x.x Signed-off-by: Charles d'Avernas --- .github/workflows/build-and-test.yml | 2 +- .github/workflows/publish.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e40dee5..baa5f3e 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 98cf47a..7f28bef 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Restore dependencies run: dotnet restore - name: Build From 40018244d486b68c51fe064ade7cff815108447c Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Thu, 19 Dec 2024 18:41:26 +0100 Subject: [PATCH 13/21] feat(Github): Replaced standard issue templates by form-based templates Signed-off-by: Charles d'Avernas --- .github/ISSUE_TEMPLATE/bug.yml | 72 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/bug_report.md | 27 --------- .github/ISSUE_TEMPLATE/feature.yml | 47 +++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 17 ------ .github/PULL_REQUEST_TEMPLATE.md | 5 ++ config.yml | 2 + 6 files changed, 126 insertions(+), 44 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug.yml delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 config.yml diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..53d706e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,72 @@ +name: Bug Report +description: Create a bug report +labels: ["bug"] +body: +- type: markdown + attributes: + value: | + :pray: Thanks for taking the time to fill out this bug report! + +- type: markdown + attributes: + value: | + ## Bug Report + +- type: textarea + id: i-tried-this + attributes: + label: "I tried this:" + placeholder: "What did you try to do? A code snippet or example helps." + validations: + required: true + +- type: textarea + id: instead-what-happened + attributes: + label: "This happened:" + placeholder: "What happened instead of what you've expected?" + validations: + required: true + +- type: textarea + id: what-did-you-expect + attributes: + label: "I expected this:" + placeholder: "What did you expect to happen? Describe the output or behavior you expected to see (unless it's obvious)." + +- type: textarea + id: workaround + attributes: + label: "Is there a workaround?" + placeholder: "What's the workaround to avoid this issue?" + +- type: textarea + attributes: + label: Anything else? + placeholder: | + Links? References? Logs? Anything that will give us more context about the issue you are encountering. + Tip: You can attach images or log files by dragging files in. + +- type: markdown + attributes: + value: | + ## Environment + +- type: dropdown + id: platform + attributes: + label: "Platform(s)" + multiple: true + options: + - MacOS + - Linux + - Windows + - Other + +- type: textarea + attributes: + label: Community Notes + value: | + + * Please vote by adding a 👍 reaction to the issue to help us prioritize. + * If you are interested to work on this issue, please leave a comment.name: Bug Report 🐞 \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index e58c0c4..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -name: Bug report -about: Create a bug report to help us improve the solution -title: 'BUG: [BUG DESCRIPTION]' -labels: bug -assignees: '' - ---- - -## Description -A clear and concise description of what the bug is. - -## How to reproduce? -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -## Expected behavior -A clear and concise description of what you expected to happen. - -## Actual behavior -A clear and concise description of what is happening. - -## Additional info -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml new file mode 100644 index 0000000..2d8bb3f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -0,0 +1,47 @@ +name: Feature Request +description: Create a feature request +labels: ["enhancement"] +body: +- type: markdown + attributes: + value: | + :pray: Thanks for taking the time to fill out this feature request! + +- type: markdown + attributes: + value: | + ## Feature Request + +- type: textarea + id: what-would-you-like-to-be-added + attributes: + label: "What would you like to be added?" + placeholder: "Description of the feature you'd like to see." + validations: + required: true + +- type: textarea + id: proposals + attributes: + label: "Proposal(s):" + placeholder: "Describe your proposal(s) and any relevant details here." + +- type: textarea + id: alternatives + attributes: + label: "Alternative(s):" + placeholder: "Describe any alternative approaches, options, or suggestions you’d like to consider." + +- type: textarea + id: additional-info + attributes: + label: "Additional info:" + placeholder: "Provide any supplementary details, context, or supporting information here." + +- type: textarea + attributes: + label: Community Notes + value: | + + * Please vote by adding a 👍 reaction to the feature to help us prioritize. + * If you are interested to work on this feature, please leave a comment. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index c262f87..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: 'Feature: [FEATURE DESCRIPTION]' -labels: enhancement -assignees: '' - ---- - -## Description -A clear and concise description of what you want to happen. - -## Alternatives -A clear and concise description of any alternative solutions or features you've considered. - -## Additional info -Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..6abd34f --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,5 @@ +**What this PR does**: + + +**Additional information:** + \ No newline at end of file diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..8e9f916 --- /dev/null +++ b/config.yml @@ -0,0 +1,2 @@ +blank_issues_enabled: false +contact_links: [] \ No newline at end of file From 506759eee6e97169bc80a261d8cdc3cd97f2eeed Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Thu, 19 Dec 2024 18:42:23 +0100 Subject: [PATCH 14/21] fix(Solution): Commited changes to the .sln file Signed-off-by: Charles d'Avernas --- Neuroglia.AsyncApi.sln | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Neuroglia.AsyncApi.sln b/Neuroglia.AsyncApi.sln index 6882bd4..1ebc492 100644 --- a/Neuroglia.AsyncApi.sln +++ b/Neuroglia.AsyncApi.sln @@ -31,6 +31,24 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreetLightsApi", "samples\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neuroglia.AsyncApi.AspNetCore", "src\Neuroglia.AsyncApi.AspNetCore\Neuroglia.AsyncApi.AspNetCore.csproj", "{9FF8A714-BFBF-4A09-87E4-57CEF088BFA7}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{4A936028-09D1-4ACD-8383-5B496DAB2E16}" + ProjectSection(SolutionItems) = preProject + .github\PULL_REQUEST_TEMPLATE.md = .github\PULL_REQUEST_TEMPLATE.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEMPLATE", "{1FB272DF-4FE6-4417-B927-98DD5A821EC0}" + ProjectSection(SolutionItems) = preProject + .github\ISSUE_TEMPLATE\bug.yml = .github\ISSUE_TEMPLATE\bug.yml + config.yml = config.yml + .github\ISSUE_TEMPLATE\feature.yml = .github\ISSUE_TEMPLATE\feature.yml + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{29E90B78-A8EE-42A1-8AE3-93D2438A9679}" + ProjectSection(SolutionItems) = preProject + .github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml + .github\workflows\publish.yml = .github\workflows\publish.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -97,6 +115,8 @@ Global {A139028A-50B1-4D62-B9A9-2D0CD438E2B0} = {4B933DF9-CD24-44B1-AF64-0D5E75B9AB45} {3A707FE1-4AA3-4232-9E7D-88376580EAD5} = {D5DC0A71-F39C-4AA1-A284-66E622868D47} {9FF8A714-BFBF-4A09-87E4-57CEF088BFA7} = {4B933DF9-CD24-44B1-AF64-0D5E75B9AB45} + {1FB272DF-4FE6-4417-B927-98DD5A821EC0} = {4A936028-09D1-4ACD-8383-5B496DAB2E16} + {29E90B78-A8EE-42A1-8AE3-93D2438A9679} = {4A936028-09D1-4ACD-8383-5B496DAB2E16} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DC433DEB-01E5-4328-B0BB-6FFFE8C7363F} From 157ce7be442357b4c549b3528af640bda1b5adaa Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Thu, 19 Dec 2024 20:33:25 +0100 Subject: [PATCH 15/21] fix(Solution): Updated the README.md file Signed-off-by: Charles d'Avernas --- Neuroglia.AsyncApi.sln | 8 ++++++- README.md | 49 +++++++++++++++++++++++------------------- config.yml | 2 -- 3 files changed, 34 insertions(+), 25 deletions(-) delete mode 100644 config.yml diff --git a/Neuroglia.AsyncApi.sln b/Neuroglia.AsyncApi.sln index 1ebc492..29b5c5a 100644 --- a/Neuroglia.AsyncApi.sln +++ b/Neuroglia.AsyncApi.sln @@ -39,7 +39,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEMPLATE", "{1FB272DF-4FE6-4417-B927-98DD5A821EC0}" ProjectSection(SolutionItems) = preProject .github\ISSUE_TEMPLATE\bug.yml = .github\ISSUE_TEMPLATE\bug.yml - config.yml = config.yml + .github\ISSUE_TEMPLATE\config.yml = .github\ISSUE_TEMPLATE\config.yml .github\ISSUE_TEMPLATE\feature.yml = .github\ISSUE_TEMPLATE\feature.yml EndProjectSection EndProject @@ -49,6 +49,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ .github\workflows\publish.yml = .github\workflows\publish.yml EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{90558701-3CBE-40D6-8E4D-A6A059C51213}" + ProjectSection(SolutionItems) = preProject + LICENSE = LICENSE + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/README.md b/README.md index 0430f94..9816f68 100644 --- a/README.md +++ b/README.md @@ -29,20 +29,20 @@ - [Streetlights API - Server](#streetlights-api---server) ## Summary -A .NET used to visualize and interact with [AsyncAPI](https://www.asyncapi.com/docs/reference/specification/v2.6.0) documents. The UI is built using Razor Pages and Boostrap +A .NET used to visualize and interact with [AsyncAPI](https://www.asyncapi.com/docs/reference/specification/v3.0.0) documents. The UI is built using Razor Pages and Boostrap ## Status `Microsoft.NET.Sdk.Web` | Name | Description | Latest Release | Spec version | | :---: | :---: | :---: | :---: | -| [Neuroglia.AsyncApi.Core](https://www.nuget.org/packages/Neuroglia.AsyncApi.Core) | Contains `AsyncAPI` models and core services such as fluent builders, validators, reader, writer and code-first generator | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.Validation](https://www.nuget.org/packages/Neuroglia.AsyncApi.Validation) | Contains services to validate `AsyncAPI` documents | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.IO](https://www.nuget.org/packages/Neuroglia.AsyncApi.IO) | Contains services to read and write `AsyncAPI` documents | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.Generation](https://www.nuget.org/packages/Neuroglia.AsyncApi.Generation) | Contains extensions and services for code-first generation of `AsyncAPI` documents | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.CloudEvents](https://www.nuget.org/packages/Neuroglia.AsyncApi.CloudEvents) | Contains fluent extensions to build Cloud Event messages | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.ServiceDependencyExtensions](https://www.nuget.org/packages/Neuroglia.AsyncApi.ServiceDependencyExtensions) | Contains extensions to configure and register `AsyncAPI` services using dependency injection | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.AspNetCore](https://www.nuget.org/packages/Neuroglia.AsyncApi.AspNetCore) | Contains an `ASP.NET` middleware used to serve `AsyncAPI` documents | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | -| [Neuroglia.AsyncApi.AspNetCore.UI](https://www.nuget.org/packages/Neuroglia.AsyncApi.AspNetCore.UI) | Contains the Razor Pages based UI for exploring `AsyncAPI` documents | [2.6.3](https://github.com/neuroglia-io/asyncapi/releases/tag/v2.6.3) | [v2.6.0](https://www.asyncapi.com/docs/reference/specification/v2.6.0) | +| [Neuroglia.AsyncApi.Core](https://www.nuget.org/packages/Neuroglia.AsyncApi.Core) | Contains `AsyncAPI` models and core services such as fluent builders, validators, reader, writer and code-first generator | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [Neuroglia.AsyncApi.Validation](https://www.nuget.org/packages/Neuroglia.AsyncApi.Validation) | Contains services to validate `AsyncAPI` documents | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [Neuroglia.AsyncApi.IO](https://www.nuget.org/packages/Neuroglia.AsyncApi.IO) | Contains services to read and write `AsyncAPI` documents | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [Neuroglia.AsyncApi.Generation](https://www.nuget.org/packages/Neuroglia.AsyncApi.Generation) | Contains extensions and services for code-first generation of `AsyncAPI` documents | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [Neuroglia.AsyncApi.CloudEvents](https://www.nuget.org/packages/Neuroglia.AsyncApi.CloudEvents) | Contains fluent extensions to build Cloud Event messages | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [Neuroglia.AsyncApi.ServiceDependencyExtensions](https://www.nuget.org/packages/Neuroglia.AsyncApi.ServiceDependencyExtensions) | Contains extensions to configure and register `AsyncAPI` services using dependency injection | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [Neuroglia.AsyncApi.AspNetCore](https://www.nuget.org/packages/Neuroglia.AsyncApi.AspNetCore) | Contains an `ASP.NET` middleware used to serve `AsyncAPI` documents | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | +| [Neuroglia.AsyncApi.AspNetCore.UI](https://www.nuget.org/packages/Neuroglia.AsyncApi.AspNetCore.UI) | Contains the Razor Pages based UI for exploring `AsyncAPI` documents | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | ## Installation @@ -95,7 +95,7 @@ dotnet add package Neuroglia.AsyncApi.AspNetCore.UI ## Usage -### Building an AsyncAPI Document +### Building an AsyncAPI V2 Document ```csharp var services = new ServiceCollection(); @@ -172,14 +172,14 @@ var asyncApi = await reader.ReadAsync(stream, cancellationToken); #### 1. Mark your services with adequate attributes ```csharp -[AsyncApi("Streetlights API", "1.0.0", Description = "The Smartylighting Streetlights API allows you to remotely manage the city lights.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] +[AsyncApiV2("Streetlights API", "1.0.0", Description = "The Smartylighting Streetlights API allows you to remotely manage the city lights.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] public class StreetLightsService : BackgroundService { ... //Omitted for brevity - [Channel("light/measured"), PublishOperation(OperationId = "onLightMeasured", Summary = "Inform about environmental lighting conditions for a particular streetlight")] + [ChannelV2("light/measured"), PublishOperation(OperationId = "onLightMeasured", Summary = "Inform about environmental lighting conditions for a particular streetlight")] public async Task PublishLightMeasured(LightMeasuredEvent e) { MqttApplicationMessage message = new() @@ -191,7 +191,7 @@ public class StreetLightsService await this.MqttClient.PublishAsync(message); } - [Channel("light/measured"), SubscribeOperation(OperationId = "lightMeasuredEvent", Summary = "Inform about environmental lighting conditions for a particular streetlight")] + [ChannelV2("light/measured"), SubscribeOperation(OperationId = "lightMeasuredEvent", Summary = "Inform about environmental lighting conditions for a particular streetlight")] protected async Task OnLightMeasured(LightMeasuredEvent e) { this.Logger.LogInformation($"Event received:{Environment.NewLine}{await this.Serializer.SerializeAsync(e)}"); @@ -204,9 +204,9 @@ public class StreetLightsService Note the usage of the following attributes: -- `AsyncApi`: Marks a class for code-first `AsyncAPI` document generation. Used to provide information about the API (licensing, contact, ...) -- `Channel`: Marks a method or class for code-first `AsyncAPI` channel generation. Used to provide information about the channel marked methods belong to. -- `Operation`: Marks a method for code-first `AsyncAPI` operation generation. Use to provide information about the `AsyncAPI` operation. +- `AsyncApiV2`: Marks a class for code-first `AsyncAPI` document generation. Used to provide information about the API (licensing, contact, ...) +- `ChannelV2`: Marks a method or class for code-first `AsyncAPI` channel generation. Used to provide information about the channel marked methods belong to. +- `OperationV2`: Marks a method for code-first `AsyncAPI` operation generation. Use to provide information about the `AsyncAPI` operation. #### 2.1. Generating documents manually @@ -214,9 +214,13 @@ Note the usage of the following attributes: var generator = serviceProvider.GetRequiredService(); var options = new AsyncApiDocumentGenerationOptions() { - DefaultConfiguration = builder => + DefaultV2Configuration = builder => { - //Setup the document by configuring servers, for example + //Setup V2 documents, by configuring servers, for example + }; + DefaultV3Configuration = builder => + { + //Setup V3 documents, by configuring servers, for example } }; IEnumerable documents = generator.GenerateAsync(typeof(StreetLightsService), options); @@ -239,9 +243,10 @@ public class Startup //Registers and configures the AsyncAPI code-first generation services.AddAsyncApiGeneration(builder => builder.WithMarkupType() - .UseDefaultConfiguration(asyncApi => + .UseDefaultV2Configuration(asyncApi => { - asyncApi.UseServer("mosquitto", server => server + asyncApi + .UseServer("mosquitto", server => server .WithUrl(new Uri("mqtt://test.mosquitto.org")) .WithProtocol(AsyncApiProtocols.Mqtt)); })); @@ -284,12 +289,12 @@ Launch your ASP project, then navigate to `http://localhost:44236/asyncapi`. You ### [Streetlights API - Server](https://github.com/neuroglia-io/AsyncApi/tree/main/samples/StreetLightsApi/Server) -A simple `ASP.NET 5.0` REST API using a MQTT-powered message bus to send and receive information about environmental lighting conditions for a particular streetlight. +A simple `ASP.NET 9.0` REST API using a MQTT-powered message bus to send and receive information about environmental lighting conditions for a particular streetlight. Clone the project in your favorite IDE, launch the app, and navigate to `https://localhost:44326/asyncapi/StreetLightsApi/1.0.0`. You should see something like the following: ```yaml -asyncapi: 2.1.0 +asyncapi: 2.6.0 info: title: Streetlights API version: 1.0.0 diff --git a/config.yml b/config.yml deleted file mode 100644 index 8e9f916..0000000 --- a/config.yml +++ /dev/null @@ -1,2 +0,0 @@ -blank_issues_enabled: false -contact_links: [] \ No newline at end of file From aff56b7155cd04b354c89c6b6744173f64295b1e Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Thu, 19 Dec 2024 20:43:52 +0100 Subject: [PATCH 16/21] fix(Solution): Fixed the README.md file Signed-off-by: Charles d'Avernas --- README.md | 63 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 9816f68..055c877 100644 --- a/README.md +++ b/README.md @@ -3,38 +3,41 @@ ## Contents - [Neuroglia AsyncAPI](#neuroglia-asyncapi) - - [Contents](#contents) - - [Summary](#summary) - - [Status](#status) - - [Installation](#installation) - - [Core library](#core-library) - - [Fluent validation library](#fluent-validation-library) - - [Fluent builders library](#fluent-builders-library) - - [Input/Output library](#inputoutput-library) - - [Code-first generation library](#code-first-generation-library) - - [Dependency inject extensions library](#dependency-inject-extensions-library) - - [Cloud event extensions library](#cloud-event-extensions-library) - - [AsyncAPI document serving library](#asyncapi-document-serving-library) - - [AsyncAPI UI](#asyncapi-ui) - - [Usage](#usage) + + [Contents](#contents) + + [Summary](#summary) + + [Status](#status) + + [Installation](#installation) + - [Core library](#core-library) + - [Fluent validation library](#fluent-validation-library) + - [Fluent builders library](#fluent-builders-library) + - [Input/Output library](#inputoutput-library) + - [Code-first generation library](#code-first-generation-library) + - [Dependency inject extensions library](#dependency-inject-extensions-library) + - [Cloud event extensions library](#cloud-event-extensions-library) + - [AsyncAPI document serving library](#asyncapi-document-serving-library) + - [AsyncAPI UI](#asyncapi-ui) + + [Usage](#usage) - [Building an AsyncAPI Document](#building-an-asyncapi-document) + + [AsyncAPI v2](#asyncapi-v2) + + [AsyncAPI v3](#asyncapi-v3) - [Writing an AsyncAPI Document](#writing-an-asyncapi-document) - [Reading an AsyncAPI document](#reading-an-asyncapi-document) - [Generating code-first AsyncAPI documents](#generating-code-first-asyncapi-documents) - - [1. Mark your services with adequate attributes](#1-mark-your-services-with-adequate-attributes) - - [2.1. Generating documents manually](#21-generating-documents-manually) - - [2.2. Generating documents automatically and serve them using ASP](#22-generating-documents-automatically-and-serve-them-using-asp) + + [AsyncAPI v2](#asyncapi-v2-1) + + [AsyncAPI v3](#asyncapi-v3-1) + - [Generating documents manually](#21-generating-documents-manually) + - [Generating documents automatically and serve them using ASP](#22-generating-documents-automatically-and-serve-them-using-asp) - [Using the AsyncAPI UI](#using-the-asyncapi-ui) - - [Samples](#samples) + + [Samples](#samples) - [Streetlights API - Server](#streetlights-api---server) ## Summary A .NET used to visualize and interact with [AsyncAPI](https://www.asyncapi.com/docs/reference/specification/v3.0.0) documents. The UI is built using Razor Pages and Boostrap ## Status -`Microsoft.NET.Sdk.Web` + | Name | Description | Latest Release | Spec version | -| :---: | :---: | :---: | :---: | +|:------|:------------|:--------------:|:------------:| | [Neuroglia.AsyncApi.Core](https://www.nuget.org/packages/Neuroglia.AsyncApi.Core) | Contains `AsyncAPI` models and core services such as fluent builders, validators, reader, writer and code-first generator | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | | [Neuroglia.AsyncApi.Validation](https://www.nuget.org/packages/Neuroglia.AsyncApi.Validation) | Contains services to validate `AsyncAPI` documents | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | | [Neuroglia.AsyncApi.IO](https://www.nuget.org/packages/Neuroglia.AsyncApi.IO) | Contains services to read and write `AsyncAPI` documents | [3.0.0](https://github.com/neuroglia-io/asyncapi/releases/tag/v3.0.0) | [v3.0.0](https://www.asyncapi.com/docs/reference/specification/v3.0.0) | @@ -95,7 +98,9 @@ dotnet add package Neuroglia.AsyncApi.AspNetCore.UI ## Usage -### Building an AsyncAPI V2 Document +### Building an AsyncAPI document + +#### AsyncAPI v2 ```csharp var services = new ServiceCollection(); @@ -152,7 +157,13 @@ var document = builder .Build(); ``` -### Writing an AsyncAPI Document +#### AsyncAPI V3 + +```csharp + +``` + +### Writing an AsyncAPI document ```csharp var writer = serviceProvider.GetRequiredService(); @@ -169,7 +180,7 @@ var asyncApi = await reader.ReadAsync(stream, cancellationToken); ### Generating code-first AsyncAPI documents -#### 1. Mark your services with adequate attributes +#### AsyncAPI V2 ```csharp [AsyncApiV2("Streetlights API", "1.0.0", Description = "The Smartylighting Streetlights API allows you to remotely manage the city lights.", LicenseName = "Apache 2.0", LicenseUrl = "https://www.apache.org/licenses/LICENSE-2.0")] @@ -208,6 +219,12 @@ Note the usage of the following attributes: - `ChannelV2`: Marks a method or class for code-first `AsyncAPI` channel generation. Used to provide information about the channel marked methods belong to. - `OperationV2`: Marks a method for code-first `AsyncAPI` operation generation. Use to provide information about the `AsyncAPI` operation. +#### AsyncAPI V3 + +```csharp + +``` + #### 2.1. Generating documents manually ```csharp From 930fc95ddfb7cebdd56e987098d65cfbf1567a58 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Fri, 20 Dec 2024 16:39:27 +0100 Subject: [PATCH 17/21] feat(UI): Added missing views, made multiple fixes and (style) improvements to existing views Signed-off-by: Charles d'Avernas --- Neuroglia.AsyncApi.sln | 7 - .../Messages/AddStreetLightRequest.cs | 3 + .../Messages/LightMeasuredEvent.cs | 2 +- ...s => MeasureStreetLightLuminosityReply.cs} | 15 +- samples/StreetLightsApi/Messages/TodoItem.cs | 34 ++++ samples/StreetLightsApi/Program.cs | 71 ++++++- .../V2OAuthFlowDefinitionViewModel.cs} | 8 +- .../V2SecurityRequirementViewModel.cs} | 8 +- .../V2SecuritySchemeDefinitionViewModel.cs} | 8 +- .../Models/v3/V3AsyncApiDocumentViewModel.cs | 2 +- ...xternalDocumentationDefinitionViewModel.cs | 28 +++ .../Models/v3/V3JsonSchemaViewModel.cs | 5 +- .../v3/V3MessageTraitDefinitionViewModel .cs | 29 +++ ...l.cs => V3OAuthFlowDefinitionViewModel.cs} | 14 +- .../v3/V3OperationTraitDefinitionViewModel.cs | 29 +++ ...l.cs => V3ParameterDefinitionViewModel.cs} | 11 +- .../v3/V3ReplyAddressDefinitionViewModel.cs | 28 +++ .../Models/v3/V3ReplyDefinitionViewModel.cs | 28 +++ .../v3/V3SecuritySchemeDefinitionViewModel.cs | 27 +++ .../v3/V3ServerVariableDefinitionViewModel.cs | 28 +++ ...wModel .cs => V3TagDefinitionViewModel.cs} | 10 +- .../Pages/Shared/_Layout.cshtml | 2 + .../Pages/Shared/v2/_V2AsyncApi.cshtml | 8 +- .../Pages/Shared/v2/_V2CorrelationId.cshtml | 2 +- .../Pages/Shared/v2/_V2Message.cshtml | 8 +- .../_V2OAuthFlow.cshtml} | 12 +- .../Pages/Shared/v2/_V2Operation.cshtml | 6 +- .../Pages/Shared/v2/_V2Schema.cshtml | 14 +- .../_V2SecurityRequirement.cshtml} | 6 +- .../Pages/Shared/v2/_V2SecurityScheme.cshtml | 24 +-- .../Pages/Shared/v2/_V2Server.cshtml | 8 +- .../Pages/Shared/v3/_V3AsyncApi.cshtml | 42 ++-- .../Pages/Shared/v3/_V3Binding.cshtml | 4 +- .../Shared/v3/_V3BindingCollection.cshtml | 4 +- .../Pages/Shared/v3/_V3Channel.cshtml | 17 +- .../Pages/Shared/v3/_V3Components.cshtml | 180 +++++++++++++----- .../Pages/Shared/v3/_V3CorrelationId.cshtml | 24 ++- .../Shared/v3/_V3ExternalDocumentation.cshtml | 10 + .../Pages/Shared/v3/_V3JsonSchema.cshtml | 14 +- .../Pages/Shared/v3/_V3Message.cshtml | 88 --------- .../Pages/Shared/v3/_V3MessageTrait.cshtml | 130 +++++++++++++ .../Pages/Shared/v3/_V3OAuthFlow.cshtml | 65 +++++++ .../Pages/Shared/v3/_V3Operation.cshtml | 85 --------- .../Shared/v3/_V3OperationMessage.cshtml | 86 --------- .../Pages/Shared/v3/_V3OperationTrait.cshtml | 128 +++++++++++++ .../Pages/Shared/v3/_V3Parameter.cshtml | 58 ++++++ .../Pages/Shared/v3/_V3Reply.cshtml | 57 ++++++ .../Pages/Shared/v3/_V3ReplyAddress.cshtml | 22 +++ .../Pages/Shared/v3/_V3Schema.cshtml | 42 ++-- .../Pages/Shared/v3/_V3SecurityScheme.cshtml | 139 ++++++++++++++ .../Pages/Shared/v3/_V3Server.cshtml | 19 +- .../Pages/Shared/v3/_V3ServerVariable.cshtml | 58 ++++++ .../Pages/Shared/v3/_V3Tag.cshtml | 43 +++++ src/Neuroglia.AsyncApi.Core/SchemaContext.cs | 33 ++++ .../V3AsyncApiDocumentExtensions.cs | 16 +- .../v3/V3ComponentDefinitionCollection.cs | 4 +- .../v3/V3OperationDefinition.cs | 2 +- ...inition.cs => V3ReplyAddressDefinition.cs} | 2 +- ...eplyDefinition.cs => V3ReplyDefinition.cs} | 4 +- .../Interfaces/IV3AsyncApiDocumentBuilder.cs | 12 +- .../IV3OperationDefinitionBuilder.cs | 4 +- ...3OperationReplyAddressDefinitionBuilder.cs | 14 +- .../IV3OperationReplyDefinitionBuilder.cs | 20 +- .../v3/Interfaces/IV3TagDefinitionBuilder.cs | 5 +- ...3OperationReplyAddressDefinitionBuilder.cs | 14 +- .../v3/V3OperationReplyDefinitionBuilder.cs | 16 +- .../v3/V3TagDefinitionBuilder.cs | 19 +- .../Cases/Core/DereferenceTests.cs | 10 +- 68 files changed, 1442 insertions(+), 533 deletions(-) rename samples/StreetLightsApi/Messages/{Todo.cs => MeasureStreetLightLuminosityReply.cs} (66%) create mode 100644 samples/StreetLightsApi/Messages/TodoItem.cs rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/{OAuthFlowDefinitionViewModel.cs => v2/V2OAuthFlowDefinitionViewModel.cs} (76%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/{SecurityRequirementViewModel.cs => v2/V2SecurityRequirementViewModel.cs} (76%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/{SecuritySchemeDefinitionViewModel.cs => v2/V2SecuritySchemeDefinitionViewModel.cs} (76%) create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ExternalDocumentationDefinitionViewModel.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageTraitDefinitionViewModel .cs rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/{V3OperationMessageDefinitionViewModel.cs => V3OAuthFlowDefinitionViewModel.cs} (56%) create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationTraitDefinitionViewModel.cs rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/{V3OperationDefinitionViewModel.cs => V3ParameterDefinitionViewModel.cs} (69%) create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyAddressDefinitionViewModel.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyDefinitionViewModel.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SecuritySchemeDefinitionViewModel.cs create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerVariableDefinitionViewModel.cs rename src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/{V3MessageDefinitionViewModel .cs => V3TagDefinitionViewModel.cs} (64%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/{_OAuthFlow.cshtml => v2/_V2OAuthFlow.cshtml} (78%) rename src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/{_SecurityRequirement.cshtml => v2/_V2SecurityRequirement.cshtml} (75%) create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3ExternalDocumentation.cshtml delete mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Message.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3MessageTrait.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3OAuthFlow.cshtml delete mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Operation.cshtml delete mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3OperationMessage.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3OperationTrait.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Parameter.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Reply.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3ReplyAddress.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3SecurityScheme.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3ServerVariable.cshtml create mode 100644 src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/v3/_V3Tag.cshtml create mode 100644 src/Neuroglia.AsyncApi.Core/SchemaContext.cs rename src/Neuroglia.AsyncApi.Core/v3/{V3OperationReplyAddressDefinition.cs => V3ReplyAddressDefinition.cs} (97%) rename src/Neuroglia.AsyncApi.Core/v3/{V3OperationReplyDefinition.cs => V3ReplyDefinition.cs} (94%) diff --git a/Neuroglia.AsyncApi.sln b/Neuroglia.AsyncApi.sln index 29b5c5a..9304da1 100644 --- a/Neuroglia.AsyncApi.sln +++ b/Neuroglia.AsyncApi.sln @@ -43,12 +43,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEM .github\ISSUE_TEMPLATE\feature.yml = .github\ISSUE_TEMPLATE\feature.yml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{29E90B78-A8EE-42A1-8AE3-93D2438A9679}" - ProjectSection(SolutionItems) = preProject - .github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml - .github\workflows\publish.yml = .github\workflows\publish.yml - EndProjectSection -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{90558701-3CBE-40D6-8E4D-A6A059C51213}" ProjectSection(SolutionItems) = preProject LICENSE = LICENSE @@ -122,7 +116,6 @@ Global {3A707FE1-4AA3-4232-9E7D-88376580EAD5} = {D5DC0A71-F39C-4AA1-A284-66E622868D47} {9FF8A714-BFBF-4A09-87E4-57CEF088BFA7} = {4B933DF9-CD24-44B1-AF64-0D5E75B9AB45} {1FB272DF-4FE6-4417-B927-98DD5A821EC0} = {4A936028-09D1-4ACD-8383-5B496DAB2E16} - {29E90B78-A8EE-42A1-8AE3-93D2438A9679} = {4A936028-09D1-4ACD-8383-5B496DAB2E16} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DC433DEB-01E5-4328-B0BB-6FFFE8C7363F} diff --git a/samples/StreetLightsApi/Messages/AddStreetLightRequest.cs b/samples/StreetLightsApi/Messages/AddStreetLightRequest.cs index 1624ca3..0b0e196 100644 --- a/samples/StreetLightsApi/Messages/AddStreetLightRequest.cs +++ b/samples/StreetLightsApi/Messages/AddStreetLightRequest.cs @@ -13,6 +13,9 @@ namespace StreetLightsApi.Messages; +/// +/// Represents a request to add a new street light +/// public class AddStreetLightRequest { diff --git a/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs b/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs index 72dab12..595ae48 100644 --- a/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs +++ b/samples/StreetLightsApi/Messages/LightMeasuredEvent.cs @@ -35,6 +35,6 @@ public class LightMeasuredEvent [Description("The event's metadata")] public IDictionary? Metadata { get; set; } - public List Todo { get; set; } = []; + public List Todo { get; set; } = []; } diff --git a/samples/StreetLightsApi/Messages/Todo.cs b/samples/StreetLightsApi/Messages/MeasureStreetLightLuminosityReply.cs similarity index 66% rename from samples/StreetLightsApi/Messages/Todo.cs rename to samples/StreetLightsApi/Messages/MeasureStreetLightLuminosityReply.cs index fa82b9a..ed0ea1d 100644 --- a/samples/StreetLightsApi/Messages/Todo.cs +++ b/samples/StreetLightsApi/Messages/MeasureStreetLightLuminosityReply.cs @@ -11,6 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace StreetLightsApi.Server.Messages; +namespace StreetLightsApi.Messages; -public record Todo(string Name); +/// +/// Represents the response to a measure street light luminosity request +/// +public class MeasureStreetLightLuminosityReply +{ + + /// + /// Gets/sets the street light's lumens + /// + public required long Lumens { get; init; } + +} \ No newline at end of file diff --git a/samples/StreetLightsApi/Messages/TodoItem.cs b/samples/StreetLightsApi/Messages/TodoItem.cs new file mode 100644 index 0000000..fe442da --- /dev/null +++ b/samples/StreetLightsApi/Messages/TodoItem.cs @@ -0,0 +1,34 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace StreetLightsApi.Server.Messages; + +/// +/// Represents a task to do +/// +/// The name of the task to do +public record TodoItem(string Name); + +/// +/// Represents the common headers of messages exchanged by the StreetLights API +/// +public record CommonHeaders +{ + + /// + /// Gets/sets the value of the header that the application's ETag + /// + [Json.Schema.Generation.Required, Json.Schema.Generation.MinLength(1)] + public required string ETag { get; init; } + +} \ No newline at end of file diff --git a/samples/StreetLightsApi/Program.cs b/samples/StreetLightsApi/Program.cs index 53b119d..aa0002f 100644 --- a/samples/StreetLightsApi/Program.cs +++ b/samples/StreetLightsApi/Program.cs @@ -54,6 +54,14 @@ { asyncApi .WithTermsOfService(new Uri("https://www.websitepolicies.com/blog/sample-terms-service-template")) + .WithExternalDocumentation(doc => doc + .WithDescription("The exhaustive documentation of the described **API**, its purpose, usage scenarios, and detailed specifications. This documentation includes all relevant architectural diagrams, authentication flows, and code samples, offering a comprehensive reference for developers and integrators.") + .WithUrl(new("https://fakeurl.com"))) + .WithTag(tag => tag + .Use("#/components/tags/kubernetes")) + .WithTag(tag => tag + .WithName("showcase") + .WithDescription("The present document is used to showcase features of the `Neuroglia.AsyncAPI` document generation.")) .WithServer("mosquitto", server => server .WithHost("mqtt://test.mosquitto.org") .WithPathName("/{environment}") @@ -67,6 +75,9 @@ ClientId = "StreetLightsAPI:1.0.0", CleanSession = true })) + .WithSchemaComponent("addStreetLighRequest", schema => schema + .WithJsonSchema(jsonSchema => jsonSchema + .FromType(Neuroglia.AsyncApi.JsonSchemaGeneratorConfiguration.Default))) .WithServerComponent("http", server => server .WithHost("https://test.com") .WithPathName("/{environment}") @@ -86,6 +97,8 @@ .WithAction(Neuroglia.AsyncApi.v3.V3OperationAction.Receive) .WithChannel("#/components/channels/lightingMeasuredHTTP") .WithDescription("Adds a new **streetlight** to the API.") + .WithTrait(trait => trait + .Use("#/components/operationTraits/commonBindings")) .WithMessage("#/components/messages/addStreetLightRequest") .WithBindings(bindings => bindings .Use("#/components/operationBindings/http"))) @@ -93,8 +106,55 @@ .WithPayloadSchema(schema => schema .WithJsonSchema(jsonSchema => jsonSchema .FromType(Neuroglia.AsyncApi.JsonSchemaGeneratorConfiguration.Default))) + .WithTrait(trait => trait + .Use("#/components/messageTraits/commonHeaders")) .WithBindings(bindings => bindings .Use("#/components/messageBindings/http"))) + .WithMessageComponent("measureStreetLightLuminosityReply", message => message + .WithPayloadSchema(schema => schema + .WithJsonSchema(jsonSchema => jsonSchema + .FromType(Neuroglia.AsyncApi.JsonSchemaGeneratorConfiguration.Default))) + .WithBindings(bindings => bindings + .Use("#/components/messageBindings/http"))) + .WithSecuritySchemeComponent("oauth2", security => security + .WithType(SecuritySchemeType.OAuth2) + .WithDescription("The security scheme used to authenticate using **OAUTH2**.") + .WithScope("api") + .WithAuthorizationScheme("Bearer") + .WithOAuthFlows(flows => flows + .WithImplicitFlow(flow => flow + .WithTokenUrl(new Uri("https://fake.com/auth/streetlights/token"))))) + .WithServerVariableComponent("environment", variable => variable + .WithDescription("The variable used to define the **hosting environment**.") + .WithDefaultValue("dev") + .WithEnumValues("dev", "staging", "production") + .WithExample("dev") + .WithExample("staging") + .WithExample("production")) + .WithParameterComponent("environment", parameter => parameter + .WithDescription("The variable used to define the **hosting environment**.") + .WithDefaultValue("dev") + .WithEnumValues("dev", "staging", "production") + .WithExample("dev") + .WithExample("staging") + .WithExample("production")) + .WithCorrelationIdComponent("streetId", correlationId => correlationId + .WithDescription("The parameter used to correlate the **street** a **light** is located in.") + .WithLocation("$message.header#/MQMD/CorrelId")) + .WithReplyComponent("measureStreetLightLuminosityReply", reply => reply + .WithChannel("#/components/channels/lightingMeasuredHTTP") + .WithAddress(address => address.Use("#/components/replyAddresses/measureStreetLightLuminosityReplyAddress")) + .WithMessage("#/components/messages/measureStreetLightLuminosityReply")) + .WithReplyAddressComponent("measureStreetLightLuminosityReplyAddress", address => address + .WithDescription("Represents the **address** to reply to after a **measureStreetLightLuminosityRequest**.") + .WithLocation("$message.header#/replyTo")) + .WithExternalDocumentationComponent("kubernetesTag", doc => doc + .WithDescription("The **external documentation** used to document the `kubernetes` **tag**.") + .WithUrl(new("https://fake.com/tags/kubernetes"))) + .WithTagComponent("kubernetes", tag => tag + .WithName("kubernetes") + .WithDescription("The **tag** used to mark a **server** deployed in `Kubernetes`.") + .WithExternalDocumentation(doc => doc.Use("#/components/externalDocs/kubernetesTag"))) .WithServerBindingsComponent("http", bindings => bindings .WithBinding(new HttpServerBindingDefinition())) .WithChannelBindingsComponent("http", bindings => bindings @@ -106,7 +166,16 @@ Type = HttpBindingOperationType.Request })) .WithMessageBindingsComponent("http", bindings => bindings - .WithBinding(new HttpMessageBindingDefinition())); + .WithBinding(new HttpMessageBindingDefinition())) + .WithOperationTraitComponent("commonBindings", trait => trait + .WithDescription("The **operation trait** used to define the bindings common to all operations defined by the application.") + .WithBinding(new HttpOperationBindingDefinition())) + .WithMessageTraitComponent("commonHeaders", trait => trait + .WithName("Common Headers") + .WithDescription("The **message trait** used to define the common headers used by all the messages exchanged by the application.") + .WithHeadersSchema(schema => schema + .WithJsonSchema(jsonSchema => jsonSchema + .FromType(Neuroglia.AsyncApi.JsonSchemaGeneratorConfiguration.Default)))); })); builder.Services.AddAsyncApiDocument(document => document .WithTitle("Cloud Event API") diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2OAuthFlowDefinitionViewModel.cs similarity index 76% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2OAuthFlowDefinitionViewModel.cs index db6bb44..814c4bd 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/OAuthFlowDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2OAuthFlowDefinitionViewModel.cs @@ -11,19 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; - -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render a view /// -public record OAuthFlowDefinitionViewModel +public record V2OAuthFlowDefinitionViewModel : V2AsyncApiDocumentViewModel { /// - public OAuthFlowDefinitionViewModel(V2AsyncApiDocument document, string parentRef, string flowType, OAuthFlowDefinition flow) : base(document) { this.ParentRef = parentRef; this.FlowType = flowType; this.Flow = flow; } + public V2OAuthFlowDefinitionViewModel(V2AsyncApiDocument document, string parentRef, string flowType, OAuthFlowDefinition flow) : base(document) { ParentRef = parentRef; FlowType = flowType; Flow = flow; } /// /// Gets a reference to the 's parent component diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SecurityRequirementViewModel.cs similarity index 76% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SecurityRequirementViewModel.cs index 600cf6e..6423f48 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecurityRequirementViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SecurityRequirementViewModel.cs @@ -11,19 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; - -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render a security requirement view /// -public record SecurityRequirementViewModel +public record V2SecurityRequirementViewModel : V2AsyncApiDocumentViewModel { /// - public SecurityRequirementViewModel(V2AsyncApiDocument document, string parentRef, string key, object? requirement) : base(document) { this.ParentRef = parentRef; this.Key = key; this.Requirement = requirement; } + public V2SecurityRequirementViewModel(V2AsyncApiDocument document, string parentRef, string key, object? requirement) : base(document) { ParentRef = parentRef; Key = key; Requirement = requirement; } /// /// Gets a reference to the requirement's parent component diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SecuritySchemeDefinitionViewModel.cs similarity index 76% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SecuritySchemeDefinitionViewModel.cs index 7e2502e..0b0e41b 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/SecuritySchemeDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v2/V2SecuritySchemeDefinitionViewModel.cs @@ -11,19 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; - -namespace Neuroglia.AsyncApi.AspNetCore.UI.Models; +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v2; /// /// Holds the data used to render a view /// -public record SecuritySchemeDefinitionViewModel +public record V2SecuritySchemeDefinitionViewModel : V2AsyncApiDocumentViewModel { /// - public SecuritySchemeDefinitionViewModel(V2AsyncApiDocument document, string parentRef, V2SecuritySchemeDefinition scheme) : base(document) { this.ParentRef = parentRef; this.Scheme = scheme; } + public V2SecuritySchemeDefinitionViewModel(V2AsyncApiDocument document, string parentRef, V2SecuritySchemeDefinition scheme) : base(document) { ParentRef = parentRef; Scheme = scheme; } /// /// Gets a reference to the parent component of the to render diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs index 6bd068d..1c9d9a8 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3AsyncApiDocumentViewModel.cs @@ -21,4 +21,4 @@ public record V3AsyncApiDocumentViewModel(V3AsyncApiDocument Document) { -} \ No newline at end of file +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ExternalDocumentationDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ExternalDocumentationDefinitionViewModel.cs new file mode 100644 index 0000000..cb098de --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ExternalDocumentationDefinitionViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The that defines the to render +/// The name of the to render +/// The to render +public record V3ExternalDocumentationDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3ExternalDocumentationDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3JsonSchemaViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3JsonSchemaViewModel.cs index 53f8265..9088291 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3JsonSchemaViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3JsonSchemaViewModel.cs @@ -17,10 +17,11 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; /// Holds the data required to render a view /// /// The that defines the to render -/// The to render +/// The to render +/// The 's context /// A reference to the component that defines the /// An containing examples of the to render -public record V3SchemaViewModel(V3AsyncApiDocument Document, V3SchemaDefinition SchemaDefinition, string ParentReference, IEnumerable? Examples = null) +public record V3SchemaViewModel(V3AsyncApiDocument Document, SchemaContext Context, V3SchemaDefinition Definition, string ParentReference, IEnumerable? Examples = null) : V3AsyncApiDocument(Document) { diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageTraitDefinitionViewModel .cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageTraitDefinitionViewModel .cs new file mode 100644 index 0000000..ce2b51b --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageTraitDefinitionViewModel .cs @@ -0,0 +1,29 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render a view +/// +/// The that defines the to render +/// The name of the to render +/// The to render +/// The index of the within its parent , if any +public record V3MessageTraitDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3MessageTraitDefinition Definition, int? Index = null) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationMessageDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OAuthFlowDefinitionViewModel.cs similarity index 56% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationMessageDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OAuthFlowDefinitionViewModel.cs index c350042..28e2158 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationMessageDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OAuthFlowDefinitionViewModel.cs @@ -14,14 +14,16 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; /// -/// Holds the data used to render a 's view +/// Holds the data used to render a view /// -/// The that defines the to render -/// The index of the to render within its parent -/// A reference to the to render -/// The to render -public record V3OperationMessageDefinitionViewModel(V3AsyncApiDocument Document, int Index, string Reference, V3MessageDefinition Message) +/// The that defines the to render +/// A reference to the to render +/// The type of the to render +/// The to render +public record V3OAuthFlowDefinitionViewModel(V3AsyncApiDocument Document, string Reference, string FlowType, OAuthFlowDefinition Flow) : V3AsyncApiDocumentViewModel(Document) { + + } \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationTraitDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationTraitDefinitionViewModel.cs new file mode 100644 index 0000000..a109bf0 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationTraitDefinitionViewModel.cs @@ -0,0 +1,29 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render a view +/// +/// The that defines the to render +/// The name of the to render +/// The to render +/// The index of the within its parent , if any +public record V3OperationTraitDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3OperationTraitDefinition Definition, int? Index = null) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ParameterDefinitionViewModel.cs similarity index 69% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationDefinitionViewModel.cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ParameterDefinitionViewModel.cs index c07e9d0..2e78126 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3OperationDefinitionViewModel.cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ParameterDefinitionViewModel.cs @@ -14,15 +14,14 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; /// -/// Holds the data used to render a view +/// Holds the data used to render an view /// -/// The that defines the to render -/// The name of the to render -/// The to render -public record V3OperationDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3OperationDefinition Definition) +/// The that defines the to render +/// The name of the to render +/// The to render +public record V3ParameterDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3ParameterDefinition Definition) : V3AsyncApiDocumentViewModel(Document) { - } diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyAddressDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyAddressDefinitionViewModel.cs new file mode 100644 index 0000000..b9be681 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyAddressDefinitionViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The that defines the to render +/// A reference to the +/// The to render +public record V3ReplyAddressDefinitionViewModel(V3AsyncApiDocument Document, string Reference, V3ReplyAddressDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyDefinitionViewModel.cs new file mode 100644 index 0000000..6e43e14 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ReplyDefinitionViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The that defines the to render +/// The to render +/// A reference to the +public record V3ReplyDefinitionViewModel(V3AsyncApiDocument Document, string Reference, V3ReplyDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SecuritySchemeDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SecuritySchemeDefinitionViewModel.cs new file mode 100644 index 0000000..f46d707 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3SecuritySchemeDefinitionViewModel.cs @@ -0,0 +1,27 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render a view +/// +/// The that defines the to render +/// A reference to the to render +/// The name of the to render +/// The to render +public record V3SecuritySchemeDefinitionViewModel(V3AsyncApiDocument Document, string Reference, string Name, V3SecuritySchemeDefinition Scheme) + : V3AsyncApiDocument(Document) +{ + +} \ No newline at end of file diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerVariableDefinitionViewModel.cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerVariableDefinitionViewModel.cs new file mode 100644 index 0000000..e2928d3 --- /dev/null +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3ServerVariableDefinitionViewModel.cs @@ -0,0 +1,28 @@ +// Copyright © 2021-Present Neuroglia SRL. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"), +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; + +/// +/// Holds the data used to render an view +/// +/// The that defines the to render +/// The name of the to render +/// The to render +public record V3ServerVariableDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3ServerVariableDefinition Definition) + : V3AsyncApiDocumentViewModel(Document) +{ + + + +} diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageDefinitionViewModel .cs b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3TagDefinitionViewModel.cs similarity index 64% rename from src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageDefinitionViewModel .cs rename to src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3TagDefinitionViewModel.cs index 5e0accc..047e0a2 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3MessageDefinitionViewModel .cs +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Models/v3/V3TagDefinitionViewModel.cs @@ -14,12 +14,12 @@ namespace Neuroglia.AsyncApi.AspNetCore.UI.Models.v3; /// -/// Holds the data used to render a view +/// Holds the data used to render an view /// -/// The that defines the to render -/// The name of the to render -/// The to render -public record V3MessageDefinitionViewModel(V3AsyncApiDocument Document, string MessageName, V3MessageDefinition Message) +/// The that defines the to render +/// The name of the to render +/// The to render +public record V3TagDefinitionViewModel(V3AsyncApiDocument Document, string Name, V3TagDefinition Definition) : V3AsyncApiDocumentViewModel(Document) { diff --git a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml index f819bc8..08d7e39 100644 --- a/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml +++ b/src/Neuroglia.AsyncApi.AspNetCore.UI/Pages/Shared/_Layout.cshtml @@ -146,6 +146,8 @@