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

dependentRequired is valid json schema but does not pass linting and prevents component from being available in UI. #1558

Open
jmacelroy opened this issue May 10, 2024 · 3 comments
Labels
good first issue Good for newcomers Type: Bug Something isn't working

Comments

@jmacelroy
Copy link

Describe the bug

Property dependentRequired is not expected here is reported when running the linter. I would expect for an OpenAPI 3.1.0 spec for this to lint and be reflected in the UI generated as it seems to be part of the supported JSON Schema dialect.T

To Reproduce
Steps to reproduce the behavior:

  1. Given this redocly.yaml file
# See https://redocly.com/docs/cli/configuration/ for more information.
extends:
  - recommended 
rules:
  no-unused-components: error
  no-server-example.com: off
  no-empty-servers: off
  security-defined: off
  info-license: off
  operation-4xx-response: off # https://phab.easypo.net/T72078 turn this back on when 4xx are added.
theme:
  openapi:
    htmlTemplate: ./docs/index.html
    theme:
      colors:
        primary:
          main: "#32329f"
    generateCodeSamples:
      languages:  # Array of language config objects; indicates in which languages to generate code samples.
        - lang: curl
  1. And this OpenAPI file(s) which is using schema example from https://json-schema.org/understanding-json-schema/reference/conditionals#dependentRequired
openapi: 3.1.0
info:
  version: 1.0.0
  title: This is only a test.
  description: testing
paths:
  '/test':
    post:
      summary: test use of dependentRequired 
      operationId: test
      responses:
        "200":
          description: "OK"
          content:
            application/json:
              schema:
                type: object
                properties:
                  name:
                    type: string
                  credit_card:
                    type: number
                  billing_address:
                    type: string
                required:
                - name
                dependentRequired:
                  credit_card:
                  - billing_address

  1. Run this command with these arguments... redocly ...
    `redocly lint openapi.yaml

  2. See error

❯ redocly lint openapi.yaml
(node:45032) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
validating openapi.yaml...
[1] openapi.yaml:27:17 at #/paths/~1test/post/responses/200/content/application~1json/schema/dependentRequired

Property `dependentRequired` is not expected here.

25 | required:
26 | - name
27 | dependentRequired:
28 |   credit_card:
29 |   - billing_address

Error was generated by the spec rule.


openapi.yaml: validated in 7ms

❌ Validation failed with 1 error.
run `redocly lint --generate-ignore-file` to add all problems to the ignore file.

Expected behavior

The lint should pass.

Logs

n/a

OpenAPI description

Included above.

Redocly Version(s)

1.12.2

Node.js Version(s)

21.6.2

Additional context

I have tried to double check that it's not just a formatting error but this looks to be correct according the the json schema doc and is not a linting error when running spectral

@jmacelroy jmacelroy added the Type: Bug Something isn't working label May 10, 2024
@tatomyr
Copy link
Contributor

tatomyr commented May 10, 2024

Hey @jmacelroy! Thanks for reporting!
Meanwhile you can suppress the error by generating the ignore file: redocly lint openapi.yaml --generate-ignore-file to pass the validation.

@tatomyr tatomyr added the good first issue Good for newcomers label May 10, 2024
@tatomyr
Copy link
Contributor

tatomyr commented May 10, 2024

BTW, what do you mean by '...prevents component from being available in UI'? Is it just linter failing and not passing to the next step or you'd expect the dependentRequired key to somehow be rendered on the UI? If the latter, you should probably open an issue in the Redoc repository.

@jmacelroy
Copy link
Author

BTW, what do you mean by '...prevents component from being available in UI'? Is it just linter failing and not passing to the next step or you'd expect the dependentRequired key to somehow be rendered on the UI? If the latter, you should probably open an issue in the Redoc repository.

It is the latter. I'll open an issue in https://github.com/Redocly/redoc. is that correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants