Module: Typelizer
- Extended by:
- Forwardable
- Defined in:
- lib/typelizer.rb,
lib/typelizer/dsl.rb,
lib/typelizer/config.rb,
lib/typelizer/listen.rb,
lib/typelizer/writer.rb,
lib/typelizer/openapi.rb,
lib/typelizer/railtie.rb,
lib/typelizer/version.rb,
lib/typelizer/property.rb,
lib/typelizer/renderer.rb,
lib/typelizer/dsl/hooks.rb,
lib/typelizer/generator.rb,
lib/typelizer/interface.rb,
lib/typelizer/type_parser.rb,
lib/typelizer/route_config.rb,
lib/typelizer/route_writer.rb,
lib/typelizer/configuration.rb,
lib/typelizer/dsl/hooks/ams.rb,
lib/typelizer/import_sorter.rb,
lib/typelizer/dsl/hooks/alba.rb,
lib/typelizer/type_inference.rb,
lib/typelizer/dsl/hooks/panko.rb,
lib/typelizer/property_sorter.rb,
lib/typelizer/route_generator.rb,
lib/typelizer/delegate_tracker.rb,
lib/typelizer/union_type_sorter.rb,
lib/typelizer/model_plugins/auto.rb,
lib/typelizer/model_plugins/poro.rb,
lib/typelizer/serializer_plugins/ams.rb,
lib/typelizer/contexts/writer_context.rb,
lib/typelizer/serializer_config_layer.rb,
lib/typelizer/serializer_plugins/alba.rb,
lib/typelizer/serializer_plugins/auto.rb,
lib/typelizer/serializer_plugins/base.rb,
lib/typelizer/dsl/hooks/oj_serializers.rb,
lib/typelizer/serializer_plugins/panko.rb,
lib/typelizer/model_plugins/active_record.rb,
lib/typelizer/serializer_plugins/oj_serializers.rb,
lib/typelizer/serializer_plugins/alba/trait_interface.rb,
lib/typelizer/serializer_plugins/alba/block_attribute_collector.rb
Defined Under Namespace
Modules: DSL, DelegateTracker, ImportSorter, Listen, ModelPlugins, OpenAPI, PropertySorter, SerializerPlugins, TypeInference, TypeParser, UnionTypeSorter Classes: Config, Configuration, Generator, Interface, Property, Railtie, Renderer, RouteConfig, RouteGenerator, RouteWriter, SerializerConfigLayer, Writer, WriterContext
Constant Summary collapse
- TYPE_MAPPING =
Hash.new(:unknown).update( boolean: :boolean, date: :string, datetime: :string, time: :string, decimal: :number, float: :number, integer: :number, string: :string, text: :string, citext: :string, uuid: :string ).freeze
- DEFAULT_TYPES_GLOBAL =
%w[Array Date Record File FileList].freeze
- CONFIGS_AFFECTING_OUTPUT =
Config keys that affect generated file content and must be included in fingerprints. When adding a new config, add it here if it affects output, or to CONFIGS_NOT_AFFECTING_OUTPUT.
%i[ types_import_path types_global prefer_double_quotes comments verbatim_module_syntax imports_sort_order properties_sort_order ].freeze
- CONFIGS_AFFECTING_INDEX_OUTPUT =
Subset of CONFIGS_AFFECTING_OUTPUT that specifically affect index.ts output.
%i[ verbatim_module_syntax prefer_double_quotes imports_sort_order ].freeze
- CONFIGS_NOT_AFFECTING_OUTPUT =
Config keys that don’t affect file content (runtime behavior, or effects captured via properties).
%i[ serializer_name_mapper filename_mapper serializer_model_mapper properties_transformer model_plugin serializer_plugin plugin_configs type_mapping null_strategy output_dir inheritance_strategy associations_strategy reject_class ].freeze
- VERSION =
"0.12.0"
Class Attribute Summary collapse
- .base_classes ⇒ Object readonly
-
.logger ⇒ Object
Returns the value of attribute logger.
Class Method Summary collapse
- .configuration ⇒ Object
- .configure {|configuration| ... } ⇒ Object
-
.enabled? ⇒ Boolean
Is Typelizer active?.
- .interfaces(writer_name: nil) ⇒ Object
- .openapi_schemas(writer_name: nil, openapi_version: "3.0") ⇒ Object
Class Attribute Details
.base_classes ⇒ Object
66 67 68 |
# File 'lib/typelizer.rb', line 66 def base_classes @base_classes end |
.logger ⇒ Object
Returns the value of attribute logger.
63 64 65 |
# File 'lib/typelizer.rb', line 63 def logger @logger end |
Class Method Details
.configuration ⇒ Object
68 69 70 |
# File 'lib/typelizer.rb', line 68 def configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
72 73 74 |
# File 'lib/typelizer.rb', line 72 def configure yield configuration end |
.enabled? ⇒ Boolean
Is Typelizer active?
Precedence: TYPELIZER env var > development? detection Legacy DISABLE_TYPELIZER is mapped to TYPELIZER with a deprecation warning.
54 55 56 57 58 59 60 61 |
# File 'lib/typelizer.rb', line 54 def enabled? migrate_legacy_env! val = ENV["TYPELIZER"] return val == "true" || val == "1" if val development? end |
.interfaces(writer_name: nil) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/typelizer.rb', line 76 def interfaces(writer_name: nil) load_serializers context = WriterContext.new(writer_name: writer_name) target_serializers(context.writer_config.reject_class) .map { |klass| context.interface_for(klass) } .reject(&:empty?) end |
.openapi_schemas(writer_name: nil, openapi_version: "3.0") ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/typelizer.rb', line 84 def openapi_schemas(writer_name: nil, openapi_version: "3.0") result = {} interfaces(writer_name: writer_name).each do |i| result[i.name] = OpenAPI.schema_for(i, openapi_version: openapi_version) i.trait_interfaces.each do |trait| result[trait.name] = OpenAPI.schema_for(trait, openapi_version: openapi_version) end end result end |