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

Missing spec validation for schema types (that redocly has) #2465

Closed
razvanphp opened this issue May 1, 2023 · 0 comments · Fixed by #2574
Closed

Missing spec validation for schema types (that redocly has) #2465

razvanphp opened this issue May 1, 2023 · 0 comments · Fixed by #2574
Assignees
Labels
enhancement New feature or request

Comments

@razvanphp
Copy link

razvanphp commented May 1, 2023

User story.
As a user switching from redocly I noticed in our CI pipeline that some errors are not displayed anymore, here is a test yaml:

openapi: 3.1.0
info:
  license: 
    name: "Apache 2.0"
    url: "https://www.apache.org/licenses/LICENSE-2.0.html"
  title: our-api
  version: '1.0'
  description: This is a base model on how you can communicate with our Portal
  contact:
    email: hell0@vamp1rebyte.ro
servers:
  - url: 'http://localhost:8337'
security:
  - BasicAuth: []
paths:
  /v1/api/config:
    parameters:
      - schema:
          type: integers
        name: id
        in: query
        required: false
        description: Id of an existing config.
      - schema:
          typ: string
        name: user_id
        in: query
        required: false
        description: Id of an existing user.
    get:
      summary: Get User Info by User ID
      operationId: get-users-settings
      description: Retrieve the information of the user settings with the matching user ID.
      tags:
        - get-user-config
      responses:
        '200':
          description: Settings for User Found
          content:
            application/json:
              schema:
                type: object
                properties:
                  key:
                    type: string,
                  value:
                    type: string
                required:
                  - key
                  - value
      parameters:
        - schema:
            type: array
          in: query
          name: prefix
          required: false
          description: Id of an existing type.
components:
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic

This is the output of spectral (with extends: 'spectral:oas'): No results with a severity of 'error' found!

but redocly shows obvious errors:

No configurations were provided -- using built in recommended configuration by default.

validating test.yaml...
[1] test.yaml:19:17 at #/paths/~1v1~1api~1config/parameters/0/schema/type

`type` can be one of the following only: "object", "array", "string", "number", "integer", "boolean", "null".

Did you mean: integer ?

17 | parameters:
18 |   - schema:
19 |       type: integers
20 |     name: id
21 |     in: query

Error was generated by the spec rule.


[2] test.yaml:25:11 at #/paths/~1v1~1api~1config/parameters/1/schema/typ

Property `typ` is not expected here.

Did you mean:
  - type
  - $id
  - id
  - not
  - if

23 |   description: Id of an existing config.
24 | - schema:
25 |     typ: string
26 |   name: user_id
27 |   in: query

Error was generated by the spec rule.


[3] test.yaml:45:27 at #/paths/~1v1~1api~1config/get/responses/200/content/application~1json/schema/properties/key/type

`type` can be one of the following only: "object", "array", "string", "number", "integer", "boolean", "null".

Did you mean: string ?

43 | properties:
44 |   key:
45 |     type: string,
46 |   value:
47 |     type: string

Error was generated by the spec rule.


[4] test.yaml:36:7 at #/paths/~1v1~1api~1config/get/responses

Operation must have at least one `4XX` response.

34 | tags:
35 |   - get-user-config
36 | responses:
37 |   '200':
38 |     description: Settings for User Found

Warning was generated by the operation-4xx-response rule.


test.yaml: validated in 13ms

❌ Validation failed with 3 errors and 1 warning.

Is your feature request related to a problem?
It might be; not sure why redocly uses more rules by default compared to spectral, but I'm inclined to think we should have those included even in the recommended ruleset.

Describe the solution you'd like
Have the schema type validated by oas spec rules similar to redocly.

Additional context

% redocly --version
1.0.0-beta.125
% spectral --version
6.6.0

Thank you in advance!
R

@mnaumanali94 mnaumanali94 added the enhancement New feature or request label May 4, 2023
@P0lip P0lip self-assigned this Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants