/// <summary>Initializes a new instance of the <see cref="SwaggerToCSharpClientGeneratorSettings"/> class.</summary> protected SwaggerToCSharpGeneratorSettings() { AdditionalNamespaceUsages = null; CSharpGeneratorSettings = new CSharpGeneratorSettings { Namespace = "MyNamespace" }; }
/// <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; }
/// <summary>Generates the JSON converters array code.</summary> /// <param name="settings">The settings.</param> /// <param name="additionalJsonConverters">The additional JSON converters.</param> /// <returns>The code.</returns> public static string GenerateJsonConvertersArrayCode(CSharpGeneratorSettings settings, IEnumerable <string> additionalJsonConverters) { var jsonConverters = GetJsonConverters(settings, additionalJsonConverters); return(GenerateConverters(jsonConverters, settings.JsonLibrary)); }
/// <summary>Initializes a new instance of the <see cref="CSharpTypeResolver"/> class.</summary> /// <param name="settings">The generator settings.</param> /// <param name="exceptionSchema">The exception type schema.</param> public CSharpTypeResolver(CSharpGeneratorSettings settings, JsonSchema4 exceptionSchema) : base(settings) { Settings = settings; ExceptionSchema = exceptionSchema; }
/// <summary>Initializes a new instance of the <see cref="CSharpDefaultValueGenerator" /> class.</summary> /// <param name="typeResolver">The type resolver.</param> /// <param name="settings">The settings.</param> public CSharpDefaultValueGenerator(ITypeResolver typeResolver, CSharpGeneratorSettings settings) : base(typeResolver, settings.EnumNameGenerator) { _settings = settings; }
/// <summary>Initializes a new instance of the <see cref="CSharpTypeResolver"/> class.</summary> /// <param name="settings">The generator settings.</param> public CSharpTypeResolver(CSharpGeneratorSettings settings) : base(settings.TypeNameGenerator) { Settings = settings; }
/// <summary>Initializes a new instance of the <see cref="CSharpTypeResolver"/> class.</summary> /// <param name="settings">The generator settings.</param> public CSharpTypeResolver(CSharpGeneratorSettings settings) { Settings = settings; }
/// <summary>Initializes a new instance of the <see cref="CSharpTypeResolver"/> class.</summary> /// <param name="settings">The generator settings.</param> /// <param name="rootObject">The root object to search for JSON Schemas.</param> public CSharpTypeResolver(CSharpGeneratorSettings settings, object rootObject) : base(settings) { _rootObject = rootObject; Settings = settings; }
/// <summary>Initializes a new instance of the <see cref="CSharpGenerator"/> class.</summary> /// <param name="schema">The schema.</param> /// <param name="settings">The generator settings.</param> public CSharpGenerator(JsonSchema4 schema, CSharpGeneratorSettings settings) : this(schema, settings, new CSharpTypeResolver(settings)) { }
/// <summary>Initializes a new instance of the <see cref="CSharpTypeResolver" /> class.</summary> /// <param name="settings">The generator settings.</param> /// <param name="exceptionSchema">The exception type schema.</param> public SwaggerToCSharpTypeResolver(CSharpGeneratorSettings settings, JsonSchema4 exceptionSchema) : base(settings) { ExceptionSchema = exceptionSchema; }
/// <summary>Initializes a new instance of the <see cref="CSharpValueGenerator" /> class.</summary> /// <param name="typeResolver">The type resolver.</param> /// <param name="settings">The settings.</param> public CSharpValueGenerator(TypeResolverBase typeResolver, CSharpGeneratorSettings settings) : base(typeResolver, settings.EnumNameGenerator) { _settings = settings; }
/// <summary>Initializes a new instance of the <see cref="CSharpGenerator"/> class.</summary> /// <param name="rootObject">The root object to search for all JSON Schemas.</param> /// <param name="settings">The generator settings.</param> /// <param name="resolver">The resolver.</param> public CSharpGenerator(object rootObject, CSharpGeneratorSettings settings, CSharpTypeResolver resolver) : base(rootObject, resolver, settings) { _resolver = resolver; Settings = settings; }
/// <summary>Initializes a new instance of the <see cref="CSharpGenerator"/> class.</summary> /// <param name="rootObject">The root object to search for all JSON Schemas.</param> /// <param name="settings">The generator settings.</param> public CSharpGenerator(object rootObject, CSharpGeneratorSettings settings) : this(rootObject, settings, new CSharpTypeResolver(settings)) { }
private static List <string> GetJsonConverters(CSharpGeneratorSettings settings, IEnumerable <string> additionalJsonConverters) { return((settings.JsonConverters ?? new string[0]).Concat(additionalJsonConverters ?? new string[0]).ToList()); }
/// <summary>Initializes a new instance of the <see cref="SwaggerToCSharpGeneratorSettings"/> class.</summary> public SwaggerToCSharpGeneratorSettings() { ClassName = "{controller}Client"; AdditionalNamespaceUsages = null; CSharpGeneratorSettings = new CSharpGeneratorSettings(); }
internal SwaggerToCSharpGenerator(SwaggerService service, CSharpGeneratorSettings settings) { Resolver = new SwaggerToCSharpTypeResolver(settings, service.Definitions); }
/// <summary>Initializes a new instance of the <see cref="CSharpValueGenerator" /> class.</summary> /// <param name="settings">The settings.</param> public CSharpValueGenerator(CSharpGeneratorSettings settings) : base(settings) { _settings = settings; }
/// <summary>Initializes a new instance of the <see cref="CSharpGenerator"/> class.</summary> /// <param name="schema">The schema.</param> /// <param name="settings">The generator settings.</param> /// <param name="resolver">The resolver.</param> public CSharpGenerator(JsonSchema4 schema, CSharpGeneratorSettings settings, CSharpTypeResolver resolver) { _schema = schema; _resolver = resolver; Settings = settings; }
/// <summary>Initializes a new instance of the <see cref="CSharpTypeResolver"/> class.</summary> /// <param name="settings">The generator settings.</param> public CSharpTypeResolver(CSharpGeneratorSettings settings) : this(settings, null) { }
public JsonSchemaToCSharpCommand() { Settings = new CSharpGeneratorSettings(); }
/// <summary>Initializes a new instance of the <see cref="CSharpTypeResolver" /> class.</summary> /// <param name="definition">The definition.</param> /// <param name="settings">The generator settings.</param> public SwaggerToCSharpTypeResolver(CSharpGeneratorSettings settings, IDictionary<string, JsonSchema4> definition) : base(settings, definition.Where(p => p.Key != "Exception").Select(p => p.Value).ToArray()) { _exceptionSchema = definition.ContainsKey("Exception") ? definition["Exception"] : null; }
public override async Task RunAsync(CommandLineProcessor processor, IConsoleHost host) { var settings = new CSharpGeneratorSettings { Namespace = Namespace, RequiredPropertiesMustBeDefined = RequiredPropertiesMustBeDefined, DateTimeType = DateTimeType }; var schema = JsonSchema4.FromJson(InputJson); var generator = new CSharpGenerator(schema, settings); var code = generator.GenerateFile(); WriteOutput(host, code); }
private static CSharpGenerator CreateGenerator() { var schema = JsonSchema4.FromType<Teacher>(); var schemaData = schema.ToJson(); var settings = new CSharpGeneratorSettings(); settings.Namespace = "MyNamespace"; var generator = new CSharpGenerator(schema, settings); return generator; }