Class: Meta::JsonSchema::RefSchema
- Inherits:
-
BaseSchema
- Object
- BaseSchema
- Meta::JsonSchema::RefSchema
- Defined in:
- lib/meta/json_schema/schemas/ref_schema.rb
Constant Summary
Constants inherited from BaseSchema
BaseSchema::OPTIONS_CHECKER, BaseSchema::USER_OPTIONS_CHECKER
Instance Attribute Summary collapse
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Attributes inherited from BaseSchema
Instance Method Summary collapse
- #filter(value, user_options = {}) ⇒ Object
-
#initialize(schema, options = {}) ⇒ RefSchema
constructor
A new instance of RefSchema.
- #to_schema_doc(user_options) ⇒ Object
Methods inherited from BaseSchema
#filter?, #find_schema, #if?, #scoped, #staged, #to_schema, #value?
Constructor Details
#initialize(schema, options = {}) ⇒ RefSchema
Returns a new instance of RefSchema.
10 11 12 13 |
# File 'lib/meta/json_schema/schemas/ref_schema.rb', line 10 def initialize(schema, = {}) super() @schema = schema end |
Instance Attribute Details
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
8 9 10 |
# File 'lib/meta/json_schema/schemas/ref_schema.rb', line 8 def schema @schema end |
Instance Method Details
#filter(value, user_options = {}) ⇒ Object
15 16 17 18 |
# File 'lib/meta/json_schema/schemas/ref_schema.rb', line 15 def filter(value, = {}) value = super schema.filter(value, ) end |
#to_schema_doc(user_options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/meta/json_schema/schemas/ref_schema.rb', line 20 def to_schema_doc() schema_name = schema.resolve_name([:stage]) # 首先将 Schema 写进 schemas 选项中去 schema_components = [:schemas] unless schema_components.key?(schema_name) schema_components[schema_name] = nil # 首先设置 schemas 防止出现无限循环 schema_components[schema_name] = schema.to_schema_doc(**) # 原地修改 schemas,无妨 end # 返回的是 $ref 结构 { '$ref': "#/components/schemas/#{schema_name}" } end |