Example #1
0
        public AuthenticationNamespace(IRootNamespace rootNamespace)
        {
            if (rootNamespace == null)
            {
                throw new ArgumentNullException(nameof(rootNamespace));
            }

            Name = QualifiedName(rootNamespace.Name, IdentifierName("Authentication"));

            Authenticators = QualifiedName(
                Name,
                IdentifierName("Authenticators"));

            IAuthenticator = QualifiedName(
                Name,
                IdentifierName("IAuthenticator"));

            MultiAuthenticator = QualifiedName(
                Name,
                IdentifierName("MultiAuthenticator"));

            SecuritySchemeSetAttribute = QualifiedName(
                Name,
                IdentifierName("SecuritySchemeSetAttribute"));
        }
Example #2
0
        public ResponsesNamespace(IRootNamespace rootNamespace)
        {
            if (rootNamespace == null)
            {
                throw new ArgumentNullException(nameof(rootNamespace));
            }

            Name = QualifiedName(rootNamespace.Name, IdentifierName("Responses"));

            IOperationResponse = QualifiedName(
                Name,
                IdentifierName("IOperationResponse"));

            OperationResponse = QualifiedName(
                Name,
                IdentifierName("OperationResponse"));

            StatusCodeMismatchException = QualifiedName(
                Name,
                IdentifierName("StatusCodeMismatchException"));

            UnknownResponse = QualifiedName(
                Name,
                IdentifierName("UnknownResponse"));
        }
 public DiscriminatorConverterTypeGeneratorFactory(GenerationContext context, IJsonSerializationNamespace jsonSerializationNamespace,
                                                   IRootNamespace rootNamespace)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
     _jsonSerializationNamespace = jsonSerializationNamespace ?? throw new ArgumentNullException(nameof(jsonSerializationNamespace));
     _rootNamespace = rootNamespace ?? throw new ArgumentNullException(nameof(rootNamespace));
 }
 public DefaultNamespaceProvider(IRootNamespace rootNamespace, IResponsesNamespace responsesNamespace,
                                 IAuthenticationNamespace authenticationNamespace)
 {
     _rootNamespace           = rootNamespace ?? throw new ArgumentNullException(nameof(rootNamespace));
     _responsesNamespace      = responsesNamespace ?? throw new ArgumentNullException(nameof(responsesNamespace));
     _authenticationNamespace = authenticationNamespace ??
                                throw new ArgumentNullException(nameof(authenticationNamespace));
 }
        public SerializationNamespace(IRootNamespace rootNamespace)
        {
            if (rootNamespace == null)
            {
                throw new ArgumentNullException(nameof(rootNamespace));
            }

            Name = QualifiedName(rootNamespace.Name, IdentifierName("Serialization"));

            HeaderSerializer = QualifiedName(
                Name,
                IdentifierName("HeaderSerializer"));

            HeaderSerializerInstance = MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
                                                              HeaderSerializer,
                                                              IdentifierName("Instance"));

            ITypeSerializer = QualifiedName(
                Name,
                IdentifierName("ITypeSerializer"));

            ITypeSerializerRegistry = QualifiedName(
                Name,
                IdentifierName("ITypeSerializerRegistry"));

            MultipartEncodingAttribute = QualifiedName(
                Name,
                IdentifierName("MultipartEncodingAttribute"));

            MultipartFormDataSerializer = QualifiedName(
                Name,
                IdentifierName("MultipartFormDataSerializer"));

            MultipartPropertyAttribute = QualifiedName(
                Name,
                IdentifierName("MultipartPropertyAttribute"));

            PathSegmentStyle = QualifiedName(
                Name,
                IdentifierName("PathSegmentStyle"));

            PathSegmentSerializer = QualifiedName(
                Name,
                IdentifierName("PathSegmentSerializer"));

            PathSegmentSerializerInstance = MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
                                                                   PathSegmentSerializer,
                                                                   IdentifierName("Instance"));

            TypeSerializerRegistryExtensions = QualifiedName(
                Name,
                IdentifierName("TypeSerializerRegistryExtensions"));

            UnknownMediaTypeException = QualifiedName(
                Name,
                IdentifierName("UnknownMediaTypeException"));
        }
Example #6
0
        public DiscriminatorConverterTypeGenerator(ILocatedOpenApiElement <OpenApiSchema> element,
                                                   GenerationContext context, ITypeGenerator?parent, IJsonSerializationNamespace jsonSerializationNamespace,
                                                   IRootNamespace rootNamespace)
            : base(element, context, parent)
        {
            _jsonSerializationNamespace = jsonSerializationNamespace ??
                                          throw new ArgumentNullException(nameof(jsonSerializationNamespace));

            _typeName = BuildTypeName(rootNamespace);
        }
Example #7
0
        protected NameSyntax BuildTypeName(IRootNamespace rootNamespace)
        {
            string rootNamespacePrefix = rootNamespace.Name + ".";
            string typeNameString      = Context.TypeGeneratorRegistry.Get(Element).TypeInfo.Name.ToString();

            // Trim the root namespace to keep the length down, if present
            var className = typeNameString.StartsWith(rootNamespacePrefix)
                ? typeNameString.Substring(rootNamespacePrefix.Length).Replace(".", "-")
                : typeNameString.Replace(".", "-");

            NameSyntax ns = _jsonSerializationNamespace.Name;

            var formatter = Context.NameFormatterSelector.GetFormatter(NameKind.Class);

            return(QualifiedName(ns, IdentifierName(formatter.Format(className + "-JsonConverter"))));
        }
        public RequestsNamespace(IRootNamespace rootNamespace)
        {
            if (rootNamespace == null)
            {
                throw new ArgumentNullException(nameof(rootNamespace));
            }

            Name = QualifiedName(rootNamespace.Name, IdentifierName("Requests"));

            IOperationRequest = QualifiedName(
                Name,
                IdentifierName("IOperationRequest"));

            OperationRequest = QualifiedName(
                Name,
                IdentifierName("OperationRequest"));
        }
Example #9
0
        public DefaultNamespaceProvider(IRootNamespace rootNamespace, IResponsesNamespace responsesNamespace,
                                        IAuthenticationNamespace authenticationNamespace, IRequestsNamespace requestsNamespace)
        {
            if (rootNamespace == null)
            {
                throw new ArgumentNullException(nameof(rootNamespace));
            }

            _responsesNamespace      = responsesNamespace ?? throw new ArgumentNullException(nameof(responsesNamespace));
            _authenticationNamespace = authenticationNamespace ??
                                       throw new ArgumentNullException(nameof(authenticationNamespace));
            _requestsNamespace = requestsNamespace ?? throw new ArgumentNullException(nameof(requestsNamespace));

            _apiNamespace        = SyntaxFactory.QualifiedName(rootNamespace.Name, SyntaxFactory.IdentifierName("Api"));
            _headersNamespace    = SyntaxFactory.QualifiedName(_responsesNamespace.Name, SyntaxFactory.IdentifierName("Headers"));
            _modelsNamespace     = SyntaxFactory.QualifiedName(rootNamespace.Name, SyntaxFactory.IdentifierName("Models"));
            _parametersNamespace = SyntaxFactory.QualifiedName(_requestsNamespace.Name, SyntaxFactory.IdentifierName("Parameters"));
        }
Example #10
0
 public ClientGenerator(IRootNamespace rootNamespace)
     : base(rootNamespace)
 {
 }
Example #11
0
 protected ResourceSyntaxTreeGenerator(GenerationContext generationContext, IRootNamespace rootNamespace)
 {
     GenerationContext = generationContext ?? throw new ArgumentNullException(nameof(generationContext));
     RootNamespace     = rootNamespace ?? throw new ArgumentNullException(nameof(rootNamespace));
 }
Example #12
0
 public ClientGenerator(GenerationContext generationContext, IRootNamespace rootNamespace)
     : base(generationContext, rootNamespace)
 {
 }
 protected ResourceSyntaxTreeGenerator(IRootNamespace rootNamespace)
 {
     RootNamespace = rootNamespace ?? throw new ArgumentNullException(nameof(rootNamespace));
 }