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

Empty strings in paths #583

Open
TheTeaCat opened this issue Nov 18, 2024 · 6 comments
Open

Empty strings in paths #583

TheTeaCat opened this issue Nov 18, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@TheTeaCat
Copy link
Contributor

Hey, thanks to #581 I've gotten my custom rule working.

Unfortunately I'm now facing an issue with the path property in the report containing empty strings.

I'm running:

vacuum spectral-report -r custom-rules.yaml my-openapi-spec.yaml spectral.json

And here's all the assets:

custom-rules.yaml
extends: [all]
documentationUrl: https://example.com/docs
rules:
  define-magic-header:
    description: Response is missing a magic header.
    severity: error
    recommended: true
    formats: [oas2, oas3]
    given: $.paths..responses..headers
    then:
      field: "MagicHeader"
      function: defined
    howToFix: Ensure that the response includes a magic header.
my-openapi-spec.yaml
swagger: 2.0
info:
  title: My OpenAPI Spec
  version: v0.0.0
paths:
  /pets:
    post:
      responses:
        200:
          description: This needs my magic header
          headers:
            NotAMagicHeader:
              description: This is not the magic header
components: {}

And then the resultant spectral.json:

[
    {
        "code": "define-magic-header",
        "path": [
            "paths",
            "",
            "responses",
            "",
            "headers"
        ],
        "message": "Response is missing a magic header.: `MagicHeader` must be defined",
        "severity": 0,
        "range": {
            "start": {
                "line": 13,
                "character": 13
            },
            "end": {
                "line": 13,
                "character": 13
            }
        },
        "source": "my-openapi-spec.yaml"
    }
]
@daveshanley
Copy link
Owner

daveshanley commented Nov 18, 2024

looks like a glitch - so it looks like the spectral-report needs a tuneup.

@daveshanley daveshanley added the bug Something isn't working label Nov 18, 2024
daveshanley added a commit that referenced this issue Nov 19, 2024
A double dot (deep search) will cause gaps in a spectral path property, this has been fixed.

This is still not a full complete fix, because the JSON path for results is calculated by the doctor, and this looks like a straight passthrough from the rule, which needs further investigation.
daveshanley added a commit that referenced this issue Nov 19, 2024
A double dot (deep search) will cause gaps in a spectral path property, this has been fixed.

This is still not a full complete fix, because the JSON path for results is calculated by the doctor, and this looks like a straight passthrough from the rule, which needs further investigation.
daveshanley added a commit that referenced this issue Nov 19, 2024
A double dot (deep search) will cause gaps in a spectral path property, this has been fixed.

This is still not a full complete fix, because the JSON path for results is calculated by the doctor, and this looks like a straight passthrough from the rule, which needs further investigation.
@daveshanley
Copy link
Owner

Should be fixed in v0.14.3

@TheTeaCat
Copy link
Contributor Author

Thanks Dave, just tried v0.14.3 and I now get a different output, but there's still empty strings:

[
    {
        "code": "define-magic-header",
        "path": [
            "paths",
            "..",
            "",
            "responses",
            "..",
            "",
            "headers"
        ],
        "message": "Response is missing a magic header.: `MagicHeader` must be defined",
        "severity": 0,
        "range": {
            "start": {
                "line": 12,
                "character": 13
            },
            "end": {
                "line": 12,
                "character": 13
            }
        },
        "source": "my-openapi-spec.yaml"
    }
]

@daveshanley
Copy link
Owner

This is very odd. It’s not what I saw at all.

I guess I need to dig deeper. It was a light weight fix that seems to be ineffective.

@daveshanley daveshanley reopened this Nov 21, 2024
@TheTeaCat
Copy link
Contributor Author

Hey @daveshanley, have you been able to dig deeper?

@daveshanley
Copy link
Owner

I have not sorry, I have been working on the doctor - which requires a lot of focus. Once the next version of the stack is released I will circle back on bugs for a while - they are stacking up a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants