question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Anchor on property which uses alias fails validation

See original GitHub issue

Schema:

{
  "title": "Field definitions schema!",
  "$schema": "http://json-schema.org/draft-04/schema#",
  "definitions": {
    "field": {
      "type": "object",
      "additionalProperties": false,
      "required": ["label"],
      "properties": {
        "label": { "type": "string" }
      }
    },
    "model": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "props": {
          "type": "object",
          "additionalProperties": { "$ref": "#/definitions/field" }
        }
      }
    }
  },
  "type": "object",
  "additionalProperties": { "$ref": "#/definitions/model" }
}

Document:

Named:
  props: &NamedProps
    name:
      label: Name

Timestamped:
  props: &TimestampedProps
    <<: *NamedProps
    ts:
      label: Timestamp

Record:
  props:
    <<: *TimestampedProps # commenting out this line removes the errors
    id:
      label: ID

Looks like it’s incorrectly adding a layer of nesting or something?

Screenshot 2020-07-08 20 25 57 Screenshot 2020-07-08 20 25 51

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JPinkneycommented, Aug 17, 2020

I haven’t been able to look into it but my hunch is that the first merge key is being properly expanded but the second one isn’t, leading to the error. The code that does that is here: https://github.com/redhat-developer/yaml-language-server/blob/master/src/languageservice/parser/jsonParser07.ts#L951 if you want to poke around

0reactions
dleavittcommented, Aug 17, 2020

Anything I can do to help? My yamls are all red 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

Schema validation doesn't work with YAML Aliases #183
YAML supports anchors and aliases, which allow nodes to be repeated in the YAML structure. This Swagger spec should be allowed, but fails...
Read more >
Advanced YAML syntax cheatsheet - Educative.io
Anchors and Aliases are YAML constructions that allow you to reduce repeat syntax and extend existing data nodes. You can place Anchors (...
Read more >
YAML Anchor, Aliases and Merge Keys
Schema-validation of a YAML document is only possible when all references and merge keys are represented. However, it is not that every schema-validator...
Read more >
Optimize GitLab CI/CD configuration files
You can reduce complexity and duplicated configuration in your GitLab CI/CD configuration files by using: YAML-specific features like anchors ( & ), aliases...
Read more >
No key with alias found in keystore - Stack Overflow
The problem seems to be with the wrongly spelled key alias In my case the alias should have been toyanath patro where I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found