spectral icon indicating copy to clipboard operation
spectral copied to clipboard

Property rules skipped for $ref'd properties

Open jeepshop opened this issue 4 years ago • 5 comments

Describe the bug Some of my casing rules don't apply to property names if the property is a $ref: This is occurring within Stoplight Studio but it seems to be a spectral issue.

To Reproduce

  1. Given this OpenAPI/AsyncAPI document model '...'
{
  "title": "Batman",
  "type": "object",
  "properties": {
    "Id": {
      "type": "integer"
    },
    "aircraftTail": {
      "$ref": "./AircraftTail.json"
    },
    "aircraft": {
      "type": "string"
    },
    "LAC": {
      "type": "integer"
    }
  }
}
  1. With this ruleset
    "model-properties-pascal-case": {
      "description": "Model properties MUST be written in PascalCase",
      "message": "{{path}} should be PascalCase",
      "severity": "warn",
      "given": "$.properties[*]~",
      "then":{
        "function":"pattern",
        "functionOptions": {
          "match": "^[A-Z][a-zA-Z0-9]*$"
        }
      }
    }

Expected behavior Both aircraftTail and aircraft should be tagged with a warning for not being PascalCased, however only aircraft is tagged. Any property that is a $ref, the property name isn't rule checked.

Screenshots image image

Environment (remove any that are not applicable):

  • Stoplight Studio 2.8.0-statble.7260
  • Windows 10

Additional context This problem is reproducible in individual models as well as within the main document rules.

jeepshop avatar Mar 15 '22 14:03 jeepshop

I suppose the rule itself is not skipped, but the error itself is attached to a different file and therefore it's not exposed in the Diagnostics pane in Studio. It's less of an issue in the context of CLI since the error should still be logged, but in the case of Studio it's more apparent since we only show errors that are specific to a particular file.

P0lip avatar Mar 15 '22 15:03 P0lip

@jeepshop jeepshop

Hi JeepShot, in the Expected behavior screenshots, which editor are you using that both marks the lines and pops up the rule ID?

michaelcilibrasi avatar Mar 23 '22 18:03 michaelcilibrasi

Hi JeepShot, in the Expected behavior screenshots, which editor are you using that both marks the lines and pops up the rule ID?

Stoplight Studio. Specifically in the Code view.

jeepshop avatar Mar 23 '22 18:03 jeepshop

I also hit an issue similar to this. But looks like now error reporting for $ref is working, but error is attached to to $ref itself instead of the property name like aircraftTail Which causes confusion and it is really hard to find where is the real error.

canvural avatar Oct 05 '23 12:10 canvural