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

Configurable rule not reporting problems #52

Closed
adamaltman opened this issue Aug 11, 2023 · 6 comments
Closed

Configurable rule not reporting problems #52

adamaltman opened this issue Aug 11, 2023 · 6 comments

Comments

@adamaltman
Copy link
Member

What happened?

I added this configurable rule, as mentioned here: Redocly/redocly-cli#1225

  rule/restful-paths:
    subject: 
      type: Paths
    assertions: 
      notPattern: '/[^{/}]+/[^{/}]+/'
    message: Two consecutive path segments don't have a variable

It does not report a problem, when running lint reports 22 problems.

What should have happened instead?

I expect to see the 22 problems.

Minimal reproducible OpenAPI snippet

Contact me.

Screenshots
n/a

Additional context

OAS 3.1, Redocly CLI 1.0.2.

@tatomyr
Copy link
Contributor

tatomyr commented Aug 14, 2023

@adamaltman I see you've closed the corresponding issue in the redocly-cli repo. Is this still valid?

@adamaltman
Copy link
Member Author

Yes, it is still valid.

@jeremyfiel
Copy link

is this still valid @adamaltman ?

works for me on the first path test/api. it doesn't capture consecutive path variables though which should be considered here.

openapi: 3.1.0
info:
  title: blah
  version: 1.1.0
paths:
  /test/api:
    get:
      parameters: 
        - name: jeremy
          in: query
          schema:
            type: string
      responses:
        "200":
          $ref: "#/components/responses/jeremy"
  /test/{test-id}/{thing}:
    get:
      parameters: 
        - name: test-id
          in: path
          schema: 
            type: string
          required: true
        - name: thing
          in: path
          schema: 
            type: string
          required: true
components:
  schemas:
    jeremy:
      anyOf:
        - type: object
          additionalProperties: false
          required:
            - test
          properties:
            test:
              type: string
        - type: string
          enum:
            - test
            - two
            - three
  responses: 
    jeremy:
      description: "test response"
      content: 
        application/json:
          schema:
            $ref: "#/components/schemas/jeremy"
          examples:
            example_response:
              $ref: examples\example.json
rule: 
  rule/restful-paths:
    subject: 
      type: Paths
    assertions: 
      notPattern: '/[^{/}]+\/[^{/}]+/'
    message: Two consecutive path segments don't have a variable

image

cli v1.0.2
windows 10

@jeremyfiel
Copy link

In the other issue you mentioned problem reporting. I see it doesn't report more than one error because there is only one instance of type Paths, so it highlights only that instance. It probably needs to report on the location child or key rather than the subject.

@RomanHotsiy
Copy link
Member

Yeah, the reporting location is wrong for sure.

Thanks @jeremyfiel 🙏

@tatomyr
Copy link
Contributor

tatomyr commented Oct 23, 2023

Fixed in v0.3.1 via Redocly/redocly-cli#1299.

@tatomyr tatomyr closed this as completed Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants