Esempio n. 1
0
        /// <summary>Initializes a new instance of the <see cref="TypeScriptClientGenerator" /> 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 TypeScriptClientGenerator(OpenApiDocument document, TypeScriptClientGeneratorSettings settings, TypeScriptTypeResolver resolver)
            : base(document, settings.CodeGeneratorSettings, resolver)
        {
            Settings = settings;

            _document = document ?? throw new ArgumentNullException(nameof(document));
            _resolver = resolver;
            _resolver.RegisterSchemaDefinitions(_document.Definitions);

            _extensionCode = new TypeScriptExtensionCode(
                Settings.TypeScriptGeneratorSettings.ExtensionCode,
                (Settings.TypeScriptGeneratorSettings.ExtendedClasses ?? new string[] { }).Concat(new[] { Settings.ConfigurationClass }).ToArray(),
                new[] { Settings.ClientBaseClass });
        }
Esempio n. 2
0
 /// <summary>Initializes a new instance of the <see cref="TypeScriptClientGenerator" /> 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 TypeScriptClientGenerator(OpenApiDocument document, TypeScriptClientGeneratorSettings settings)
     : this(document, settings, new TypeScriptTypeResolver(settings.TypeScriptGeneratorSettings))
 {
 }