A resolver which returns Exception without generating the class (uses System.Exception instead of own class).
Inheritance: CSharpTypeResolver
コード例 #1
0
        /// <summary>Initializes a new instance of the <see cref="SwaggerToCSharpClientGenerator" /> class.</summary>
        /// <param name="document">The Swagger document.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="resolver">The resolver.</param>
        /// <exception cref="ArgumentNullException"><paramref name="document" /> is <see langword="null" />.</exception>
        public SwaggerToCSharpClientGenerator(SwaggerDocument document, SwaggerToCSharpClientGeneratorSettings settings, SwaggerToCSharpTypeResolver resolver)
            : base(document, settings, resolver)
        {
            if (document == null)
                throw new ArgumentNullException(nameof(document));

            Settings = settings;
            _document = document;
        }
コード例 #2
0
        /// <summary>Creates a new resolver, adds the given schema definitions and registers an exception schema if available.</summary>
        /// <param name="settings">The settings.</param>
        /// <param name="definitions">The definitions.</param>
        public static SwaggerToCSharpTypeResolver CreateWithDefinitions(CSharpGeneratorSettings settings, IDictionary<string, JsonSchema4> definitions)
        {
            var exceptionSchema = definitions.ContainsKey("Exception") ? definitions["Exception"] : null;

            var resolver = new SwaggerToCSharpTypeResolver(settings, exceptionSchema);
            resolver.AddGenerators(definitions
                .Where(p => p.Value != exceptionSchema)
                .ToDictionary(p => p.Key, p => p.Value));

            return resolver;
        }
コード例 #3
0
        /// <summary>Creates a new resolver, adds the given schema definitions and registers an exception schema if available.</summary>
        /// <param name="settings">The settings.</param>
        /// <param name="definitions">The definitions.</param>
        public static SwaggerToCSharpTypeResolver CreateWithDefinitions(CSharpGeneratorSettings settings, IDictionary <string, JsonSchema4> definitions)
        {
            var exceptionSchema = definitions.ContainsKey("Exception") ? definitions["Exception"] : null;

            var resolver = new SwaggerToCSharpTypeResolver(settings, exceptionSchema);

            resolver.AddSchemas(definitions
                                .Where(p => p.Value != exceptionSchema)
                                .ToDictionary(p => p.Key, p => p.Value));

            return(resolver);
        }
コード例 #4
0
        internal SwaggerToCSharpGeneratorBase(SwaggerService service, SwaggerToCSharpGeneratorSettings settings)
        {
            _service  = service;
            _settings = settings;

            foreach (var definition in _service.Definitions.Where(p => string.IsNullOrEmpty(p.Value.TypeNameRaw)))
            {
                definition.Value.TypeNameRaw = definition.Key;
            }

            var exceptionSchema = _service.Definitions.ContainsKey("Exception") ? _service.Definitions["Exception"] : null;

            Resolver = new SwaggerToCSharpTypeResolver(settings.CSharpGeneratorSettings, exceptionSchema);
            Resolver.AddSchemas(service.Definitions.Where(p => p.Value != exceptionSchema).ToDictionary(p => p.Key, p => p.Value));
        }
コード例 #5
0
        /// <summary>Initializes a new instance of the <see cref="SwaggerToCSharpClientGenerator" /> class.</summary>
        /// <param name="service">The service.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="resolver">The resolver.</param>
        /// <exception cref="ArgumentNullException"><paramref name="service" /> is <see langword="null" />.</exception>
        public SwaggerToCSharpClientGenerator(SwaggerService service, SwaggerToCSharpClientGeneratorSettings settings, SwaggerToCSharpTypeResolver resolver)
            : base(service, settings, resolver)
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            Settings = settings;

            _service = service;
            foreach (var definition in _service.Definitions.Where(p => string.IsNullOrEmpty(p.Value.TypeNameRaw)))
            {
                definition.Value.TypeNameRaw = definition.Key;
            }
        }
コード例 #6
0
 /// <summary>Initializes a new instance of the <see cref="SwaggerToCSharpClientGenerator" /> class.</summary>
 /// <param name="service">The service.</param>
 /// <param name="settings">The settings.</param>
 /// <exception cref="System.ArgumentNullException">service</exception>
 /// <exception cref="ArgumentNullException"><paramref name="service" /> is <see langword="null" />.</exception>
 public SwaggerToCSharpClientGenerator(SwaggerService service, SwaggerToCSharpClientGeneratorSettings settings)
     : this(service, settings, SwaggerToCSharpTypeResolver.CreateWithDefinitions(settings.CSharpGeneratorSettings, service.Definitions))
 {
 }
コード例 #7
0
 internal SwaggerToCSharpGeneratorBase(SwaggerDocument document, SwaggerToCSharpGeneratorSettings settings, SwaggerToCSharpTypeResolver resolver)
     : base(resolver, settings.CodeGeneratorSettings)
 {
     _document = document;
     _settings = settings;
 }
コード例 #8
0
 internal SwaggerToCSharpGenerator(SwaggerService service, CSharpGeneratorSettings settings)
 {
     Resolver = new SwaggerToCSharpTypeResolver(settings, service.Definitions);
 }
コード例 #9
0
        internal SwaggerToCSharpGeneratorBase(SwaggerDocument document, SwaggerToCSharpGeneratorSettings settings, SwaggerToCSharpTypeResolver resolver)
            : base(resolver, settings.CodeGeneratorSettings)
        {
            _document = document;
            _settings = settings;

            foreach (var definition in _document.Definitions.Where(p => string.IsNullOrEmpty(p.Value.TypeNameRaw)))
            {
                definition.Value.TypeNameRaw = definition.Key;
            }
        }
コード例 #10
0
        /// <summary>Initializes a new instance of the <see cref="SwaggerToCSharpWebApiControllerGenerator" /> class.</summary>
        /// <param name="document">The Swagger document.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="resolver">The resolver.</param>
        /// <exception cref="ArgumentNullException"><paramref name="document" /> is <see langword="null" />.</exception>
        public SwaggerToCSharpWebApiControllerGenerator(SwaggerDocument document, SwaggerToCSharpWebApiControllerGeneratorSettings settings, SwaggerToCSharpTypeResolver resolver)
            : base(document, settings, resolver)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            Settings  = settings;
            _document = document;
        }
コード例 #11
0
 /// <summary>Initializes a new instance of the <see cref="SwaggerToCSharpWebApiControllerGenerator" /> class.</summary>
 /// <param name="document">The Swagger document.</param>
 /// <param name="settings">The settings.</param>
 /// <exception cref="ArgumentNullException"><paramref name="document" /> is <see langword="null" />.</exception>
 public SwaggerToCSharpWebApiControllerGenerator(SwaggerDocument document, SwaggerToCSharpWebApiControllerGeneratorSettings settings)
     : this(document, settings, SwaggerToCSharpTypeResolver.CreateWithDefinitions(settings.CSharpGeneratorSettings, document.Definitions))
 {
 }
コード例 #12
0
 internal SwaggerToCSharpGenerator(SwaggerService service, CSharpGeneratorSettings settings)
 {
     Resolver = new SwaggerToCSharpTypeResolver(settings, service.Definitions);
 }
コード例 #13
0
        /// <summary>Initializes a new instance of the <see cref="SwaggerToCSharpWebApiControllerGenerator" /> class.</summary>
        /// <param name="document">The Swagger document.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="resolver">The resolver.</param>
        /// <exception cref="ArgumentNullException"><paramref name="document" /> is <see langword="null" />.</exception>
        public SwaggerToCSharpWebApiControllerGenerator(SwaggerDocument document, SwaggerToCSharpWebApiControllerGeneratorSettings settings, SwaggerToCSharpTypeResolver resolver)
            : base(document, settings, resolver)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            Settings = settings;

            _document = document;
            foreach (var definition in _document.Definitions.Where(p => string.IsNullOrEmpty(p.Value.TypeNameRaw)))
            {
                definition.Value.TypeNameRaw = definition.Key;
            }
        }
コード例 #14
0
        internal SwaggerToCSharpGeneratorBase(SwaggerService service, SwaggerToCSharpGeneratorSettings settings, SwaggerToCSharpTypeResolver resolver)
            : base(resolver)
        {
            _service  = service;
            _settings = settings;

            foreach (var definition in _service.Definitions.Where(p => string.IsNullOrEmpty(p.Value.TypeNameRaw)))
            {
                definition.Value.TypeNameRaw = definition.Key;
            }
        }
コード例 #15
0
 internal SwaggerToCSharpGeneratorBase(SwaggerDocument document, SwaggerToCSharpGeneratorSettings settings, SwaggerToCSharpTypeResolver resolver)
     : base(resolver, settings.CodeGeneratorSettings)
 {
     _document = document;
     _settings = settings;
 }