Class: Rage::OpenAPI::Parsers::Ext::Blueprinter
- Inherits:
-
Object
- Object
- Rage::OpenAPI::Parsers::Ext::Blueprinter
- Defined in:
- lib/rage/openapi/parsers/ext/blueprinter.rb
Defined Under Namespace
Classes: InvalidViewError
Instance Method Summary collapse
-
#initialize(namespace: Object, root: Rage::OpenAPI::Nodes::Root.new) ⇒ Blueprinter
constructor
A new instance of Blueprinter.
- #known_definition?(str) ⇒ Boolean
- #parse(klass_str) ⇒ Object
Constructor Details
#initialize(namespace: Object, root: Rage::OpenAPI::Nodes::Root.new) ⇒ Blueprinter
Returns a new instance of Blueprinter.
6 7 8 9 10 |
# File 'lib/rage/openapi/parsers/ext/blueprinter.rb', line 6 def initialize(namespace: Object, root: Rage::OpenAPI::Nodes::Root.new, **) @namespace = namespace @root = root @parsing_stack = Set.new end |
Instance Method Details
#known_definition?(str) ⇒ Boolean
12 13 14 15 16 17 |
# File 'lib/rage/openapi/parsers/ext/blueprinter.rb', line 12 def known_definition?(str) _, str, _ = Rage::OpenAPI.__parse_serializer_args(str) defined?(Blueprinter::Base) && @namespace.const_get(str).ancestors.include?(Blueprinter::Base) rescue NameError false end |
#parse(klass_str) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rage/openapi/parsers/ext/blueprinter.rb', line 19 def parse(klass_str) is_collection, raw_klass_str, = Rage::OpenAPI.__parse_serializer_args(klass_str) klass = @namespace.const_get(raw_klass_str) schema = build_schema(klass, is_collection, ) if @root.schema_registry.key?(raw_klass_str) @root.schema_registry[raw_klass_str] = is_collection ? schema["items"] : schema end schema rescue InvalidViewError => e Rage::OpenAPI.__log_warn e. end |