Skip to content

refractorPluginReplaceEmptyElement not applied to schema properties member / empty keys #969

@frantuma

Description

@frantuma

while parsing YAML applying refractorPluginReplaceEmptyElement, schema properties member doesn't be parsed into a semantic Schema element, as occurring "correctly" for other empty keys like e.g components.schemas members.

Example below demonstrates the issue:

asyncapi: '2.2.0'
components:
  schemas:
    foo:

    bad:
      type: object
      properties:
        car:
          
    bar:
      type: string
      

results in:

asyncApi2 [ 'api', 'result' ] [0 / 0:0 - 13:0] {
  asyncapi: '2.2.0',
  components: { schemas: { foo: {}, bad: [Object], bar: [Object] } }
}
member [ 'fixed-field' ] [0 / 0:0 - 0:17] { key: 'asyncapi', value: '2.2.0' }
string [] [0 / 0:0 - 0:8] asyncapi
asyncApiVersion [ 'spec-version', 'version' ] [10 / 0:10 - 0:17] 2.2.0
member [ 'fixed-field' ] [18 / 1:0 - 13:0] {
  key: 'components',
  value: { schemas: { foo: {}, bad: [Object], bar: [Object] } }
}
string [] [18 / 1:0 - 1:10] components
components [] [32 / 2:2 - 13:0] {
  schemas: {
    foo: {},
    bad: { type: 'object', properties: [Object] },
    bar: { type: 'string' }
  }
}
member [ 'fixed-field' ] [32 / 2:2 - 13:0] {
  key: 'schemas',
  value: {
    foo: {},
    bad: { type: 'object', properties: [Object] },
    bar: { type: 'string' }
  }
}
string [] [32 / 2:2 - 2:9] schemas
object [ 'components-schemas' ] [45 / 3:4 - 13:0] {
  foo: {},
  bad: { type: 'object', properties: { car: '' } },
  bar: { type: 'string' }
}
member [ 'patterned-field' ] [45 / 3:4 - 3:8] { key: 'foo', value: {} }
string [] [45 / 3:4 - 3:7] foo

parsing components.schemas correctly:

schema [ 'yaml-e-node', 'yaml-e-scalar' ] [49 / 3:8 - 3:8] {}

member [ 'patterned-field' ] [55 / 5:4 - 8:12] { key: 'bad', value: { type: 'object', properties: { car: '' } } }
string [] [55 / 5:4 - 5:7] bad
schema [] [66 / 6:6 - 8:12] { type: 'object', properties: { car: '' } }
member [ 'fixed-field' ] [66 / 6:6 - 6:18] { key: 'type', value: 'object' }
string [] [66 / 6:6 - 6:10] type
string [ 'json-schema-type' ] [72 / 6:12 - 6:18] object
member [ 'fixed-field' ] [85 / 7:6 - 8:12] { key: 'properties', value: { car: '' } }
string [] [85 / 7:6 - 7:16] properties
object [ 'json-schema-properties' ] [105 / 8:8 - 8:12] { car: '' }
member [ 'patterned-field' ] [105 / 8:8 - 8:12] { key: 'car', value: '' }
string [] [105 / 8:8 - 8:11] car

NOT parsing schema.properties semantically:

string [ 'yaml-e-node', 'yaml-e-scalar' ] [109 / 8:12 - 8:12] 

member [ 'patterned-field' ] [125 / 10:4 - 13:0] { key: 'bar', value: { type: 'string' } }
string [] [125 / 10:4 - 10:7] bar
schema [] [136 / 11:6 - 13:0] { type: 'string' }
member [ 'fixed-field' ] [136 / 11:6 - 11:18] { key: 'type', value: 'string' }
string [] [136 / 11:6 - 11:10] type
string [ 'json-schema-type' ] [142 / 11:12 - 11:18] string

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions