コード例 #1
0
        public NSwagCSharpOptions(INSwagOptions options = null)
        {
            try
            {
                if (options == null)
                {
                    options = GetFromDialogPage();
                }

                InjectHttpClient         = options.InjectHttpClient;
                GenerateClientInterfaces = options.GenerateClientInterfaces;
                GenerateDtoTypes         = options.GenerateDtoTypes;
                UseBaseUrl = options.UseBaseUrl;
                ClassStyle = options.ClassStyle;
            }
            catch (Exception e)
            {
                Trace.WriteLine(e);
                Trace.WriteLine(Environment.NewLine);
                Trace.WriteLine("Error reading user options. Reverting to default values");
                Trace.WriteLine("InjectHttpClient = true");
                Trace.WriteLine("GenerateClientInterfaces = true");
                Trace.WriteLine("GenerateDtoTypes = true");
                Trace.WriteLine("UseBaseUrl = false");
                Trace.WriteLine("ClassStyle = CSharpClassStyle.Poco");

                InjectHttpClient         = true;
                GenerateClientInterfaces = true;
                GenerateDtoTypes         = true;
                UseBaseUrl = false;
                ClassStyle = CSharpClassStyle.Poco;
            }
        }
コード例 #2
0
        public void OnExecuteAsync_Should_NotThrow(
            IConsoleOutput console,
            IProgressReporter progressReporter,
            IOpenApiDocumentFactory openApiDocumentFactory,
            INSwagOptions options,
            INSwagCodeGeneratorFactory codeGeneratorFactory,
            ICodeGenerator generator,
            string outputFile,
            string code)
        {
            var sut = new NSwagCommand(
                console,
                progressReporter,
                openApiDocumentFactory,
                options,
                codeGeneratorFactory);

            sut.OutputFile = outputFile;

            Mock.Get(generator)
            .Setup(c => c.GenerateCode(progressReporter))
            .Returns(code);

            new Func <int>(sut.OnExecute).Should().NotThrow();
        }
コード例 #3
0
 public ICodeGenerator Create(
     string swaggerFile,
     string defaultNamespace,
     INSwagOptions options,
     IOpenApiDocumentFactory documentFactory)
 => new NSwagCSharpCodeGenerator(
     swaggerFile,
     documentFactory,
     new NSwagCodeGeneratorSettingsFactory(defaultNamespace, options));
コード例 #4
0
 public NSwagSingleFileCustomTool(
     INSwagCodeGeneratorFactory factory,
     IOpenApiDocumentFactory openApiDocumentFactory,
     INSwagOptions options)
 {
     this.factory = factory ?? throw new ArgumentNullException(nameof(factory));
     this.openApiDocumentFactory = openApiDocumentFactory ??
                                   throw new ArgumentNullException(nameof(openApiDocumentFactory));
     this.options = options ?? throw new ArgumentNullException(nameof(options));
 }
コード例 #5
0
 public NSwagCommand(
     IConsoleOutput console,
     IProgressReporter progressReporter,
     IOpenApiDocumentFactory openApiDocumentFactory,
     INSwagOptions options,
     INSwagCodeGeneratorFactory codeGeneratorFactory)
     : base(console, progressReporter)
 {
     this.openApiDocumentFactory = openApiDocumentFactory ?? throw new ArgumentNullException(nameof(openApiDocumentFactory));
     this.options = options ?? throw new ArgumentNullException(nameof(options));
     this.codeGeneratorFactory = codeGeneratorFactory ?? throw new ArgumentNullException(nameof(codeGeneratorFactory));
 }
コード例 #6
0
 public void Create_Should_Return_NotNull(
     NSwagCodeGeneratorFactory sut,
     string swaggerFile,
     string defaultNamespace,
     INSwagOptions options,
     IOpenApiDocumentFactory documentFactory)
 => sut.Create(
     swaggerFile,
     defaultNamespace,
     options,
     documentFactory)
 .Should()
 .NotBeNull();
 public NSwagCodeGeneratorSettingsFactory(string defaultNamespace, INSwagOptions options)
 {
     this.defaultNamespace = defaultNamespace ?? throw new ArgumentNullException(nameof(defaultNamespace));
     this.options          = options ?? throw new ArgumentNullException(nameof(options));
 }
コード例 #8
0
 public void Init()
 => options = new Mock <INSwagOptions>().Object;
コード例 #9
0
 public NSwagCSharpCodeGenerator(string swaggerFile, string defaultNamespace, INSwagOptions options)
 {
     this.swaggerFile      = swaggerFile ?? throw new ArgumentNullException(nameof(swaggerFile));
     this.defaultNamespace = defaultNamespace ?? throw new ArgumentNullException(nameof(defaultNamespace));
     this.options          = new NSwagCSharpOptions(options ?? throw new ArgumentNullException(nameof(options)));
 }