Redocly / redocly-vs-code

Redocly VS Code extension
35 stars 6 forks source link

Configurable rule not reporting problems #52

Closed adamaltman closed 10 months ago

adamaltman commented 1 year ago

What happened?

I added this configurable rule, as mentioned here: https://github.com/Redocly/redocly-cli/issues/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 commented 1 year ago

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

adamaltman commented 1 year ago

Yes, it is still valid.

jeremyfiel commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

Yeah, the reporting location is wrong for sure.

Thanks @jeremyfiel 🙏

tatomyr commented 10 months ago

Fixed in v0.3.1 via https://github.com/Redocly/redocly-cli/pull/1299.