Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property rules skipped for $ref'd properties #2091

Open
jeepshop opened this issue Mar 15, 2022 · 4 comments
Open

Property rules skipped for $ref'd properties #2091

jeepshop opened this issue Mar 15, 2022 · 4 comments
Labels
json-refs everything JSON Refs resolving related t/bug Something isn't working triaged

Comments

@jeepshop
Copy link

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.

@P0lip
Copy link
Contributor

P0lip commented Mar 15, 2022

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 P0lip added the t/bug Something isn't working label Mar 15, 2022
@michaelcilibrasi
Copy link

@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?

@jeepshop
Copy link
Author

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.

@P0lip P0lip added the json-refs everything JSON Refs resolving related label Mar 24, 2022
@canvural
Copy link

canvural commented Oct 5, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
json-refs everything JSON Refs resolving related t/bug Something isn't working triaged
Projects
None yet
Development

No branches or pull requests

5 participants