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

feature request: Hide AJVs "unknown format" complaints #396

Closed
nulltoken opened this issue Jul 20, 2019 · 7 comments · Fixed by #503
Closed

feature request: Hide AJVs "unknown format" complaints #396

nulltoken opened this issue Jul 20, 2019 · 7 comments · Fixed by #503
Assignees
Labels
enhancement New feature or request p/low sev/minor t/bug Something isn't working

Comments

@nulltoken
Copy link
Contributor

Describe the bug

According to the spec, format is is an open string-valued property, and can have any value.
Spectral generates (pollutes?) stdout with warnings about "unknown format"s.

To Reproduce

repro/output.openapi.yaml

openapi: 3.0.0
servers:
  - url: "https://ex-ample.com"
x-format-version: "1.0"
info:
  title: Four
  description: Issue repro 4
  contact:
    email: e@e.com
  version: 0.0.0
paths: {}
components:
  schemas:
    AModel:
      description: Yet another self descriptive explanation
      type: object
      properties:
        a_country:
          description: Guess what? A country.
          type: string
          format: "ISO-3166-1 alpha-2"
          example: de

Run

$ yarn spectral lint repro/output.openapi.yaml -o repro/log.txt -q
yarn run v1.15.2
$ C:\REDACTED\node_modules\.bin\spectral lint repro/output2.openapi.yaml -o repro/log.txt -q
unknown format "ISO-3166-1 alpha-2" ignored in schema at path "#"
unknown format "ISO-3166-1 alpha-2" ignored in schema at path "#"
Done in 1.52s.

repro/log.txt

(empty)

Expected behavior
Nothing in stderr/stdout

Environment (remove any that are not applicable):

  • Library version: 4.0.1
  • OS: Windows 7
@nulltoken nulltoken added the t/bug Something isn't working label Jul 20, 2019
@philsturgeon philsturgeon changed the title Inconsitent reporting of formats feature request: Hide AJVs "unknown format" complaints Jul 20, 2019
@philsturgeon
Copy link
Contributor

Hey there, this related to ajv-validator/ajv#466 in which the author of AJV makes it very clear that people should be aware of unknown formats.

I would like to try and hide these specific messages because you are correct, the OAS spec does say you can use whatever you want.

@philsturgeon philsturgeon added this to the September '19 Hardening milestone Aug 14, 2019
@marbemac marbemac modified the milestones: August '19 Hardening, Aug '19 Hardening Aug 20, 2019
@chris-miaskowski chris-miaskowski self-assigned this Aug 29, 2019
@chris-miaskowski
Copy link
Contributor

chris-miaskowski commented Aug 29, 2019

Hey folks, now reading through that issue @philsturgeon linked to and the maintainer has a valid point.

"ignore" - to log warning during schema compilation and always pass validation (the default behaviour in versions before 5.0.0). This option is not recommended, as it allows to mistype format name and it won’t be validated without any error message. This behaviour is required by JSON Schema specification.

I see three possible solutions:

@philsturgeon
Copy link
Contributor

If you'd like to try and find a way to convert these CLI outputs to spectral warnings then that's ok, but JSON Schema allows unknown formats so we should not shove all this stuff into the CLI when unknown formats are discovered. 🤷‍♂

A large part of the problem here, and something this issue is aiming to address, is that these are shoved into the console outside of normal spectral logic, so --quiet isnt helping get rid of them.

@chris-miaskowski
Copy link
Contributor

If you'd like to try and find a way to convert these CLI outputs to spectral warnings then that's ok, but JSON Schema allows unknown formats so we should not shove all this stuff into the CLI when unknown formats are discovered. man_shrugging

Oh, interesting, that's a forth solution which I haven't thought about. Good idea. Ok, will play around with this stuff and see where I can take it.

@philsturgeon
Copy link
Contributor

Maybe spike on it and see how far you get. The primary goal is to get the AJV format moaning out of the console, and maybe a follow up feature could be to have those format messages converted to spectral warnings or info :)

@chris-miaskowski
Copy link
Contributor

yo, created a PR, please take a look if that's sufficient.

@chris-miaskowski
Copy link
Contributor

chris-miaskowski commented Aug 29, 2019

and maybe a follow up feature could be to have those format messages converted to spectral warnings or info :)

Sounds good. Had a quick look and surfacing it at the spectral messages level will require some more work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p/low sev/minor t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants