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; } }
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(); }
public ICodeGenerator Create( string swaggerFile, string defaultNamespace, INSwagOptions options, IOpenApiDocumentFactory documentFactory) => new NSwagCSharpCodeGenerator( swaggerFile, documentFactory, new NSwagCodeGeneratorSettingsFactory(defaultNamespace, options));
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)); }
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)); }
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)); }
public void Init() => options = new Mock <INSwagOptions>().Object;
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))); }