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

Update ajv to 6.11 to fully support date-time format spec #980

Closed
1 task
jababda opened this issue Feb 21, 2020 · 5 comments
Closed
1 task

Update ajv to 6.11 to fully support date-time format spec #980

jababda opened this issue Feb 21, 2020 · 5 comments
Labels

Comments

@jababda
Copy link

jababda commented Feb 21, 2020

Chore summary
Update ajv to the latest version to get full date time support for schema validation.
Right now the 6.10 version isn't compliant with the full date-time iso format spec that oas supports.

Tasks

  • Update line 69 of package.json to ^6.11
@jababda jababda added the chore label Feb 21, 2020
@nulltoken
Copy link
Contributor

👋🏻 Could you please provide an example of what doesn’t work today and would be fixed with this upgrade?

@jababda
Copy link
Author

jababda commented Feb 21, 2020

Specifically this issue ajv-validator/ajv#1061.
In our context want to make it clear to the consumers of the spec that we are expecting a date time with a time-offset. We can not include the example while using spectral and its schema validation rules.

@nulltoken
Copy link
Contributor

@jababda Thanks for your answer. I now realize my initial request was badly expressed. Let me give it another try. ;-)

Could you please provide us with the smallest possible OpenAPi document, that fails the validation with current Spectral version but would pass with an updated ajv?

We do our best to cover any change (and especially bugs) with automated tests to guard against future regressions, and in order to add a test for this change, we'd need this concrete example of what is being fixed.

Or... if you feel adventurous (:wink:) and open to it, you could send a pull request with the fix and the test covering it (with regards to the test, the simplest possible change for you would be to add an an end-to-end test similar to https://github.com/stoplightio/spectral/blob/develop/test-harness/scenarios/results-default.oas3.scenario

@jababda
Copy link
Author

jababda commented Feb 24, 2020

openapi: 3.0.0
info:
  title: Date Test
  version: 1.0.0
paths:
  /sample:
    get:
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  sampleDate:
                    type: string
                    format: date-time
              example: { "sampleDate": "2020-02-10T00:00:00.000+8:00" }

Produces

  1:1   warning  oas3-api-servers                OpenAPI `servers` must be present and non-empty array.
  1:1   warning  openapi-tags                    OpenAPI object should have non-empty `tags` array.
  2:6   warning  info-contact                    Info object should contain `contact` object.
  2:6   warning  info-description                OpenAPI object info `description` must be present and non-empty string.
  7:9   warning  operation-description           Operation `description` must be present and non-empty string.
  7:9   warning  operation-operationId           Operation should have an `operationId`.
  7:9   warning  operation-tags                  Operation should have non-empty `tags` array.
 19:23  warning  example-value-or-externalValue  Example should have either a `value` or `externalValue` field.
 19:40    error  oas3-valid-oas-content-example  `sampleDate` property format should match format `date-time`

✖ 9 problems (1 error, 8 warnings, 0 infos, 0 hints)

The latest ajv update should resolve this the error.
Sorry for the misunderstanding! I'll hopefully be able to create a PR + test for this soon :).

@jababda
Copy link
Author

jababda commented Feb 25, 2020

I was totally wrong, my example does not follow the https://tools.ietf.org/html/rfc3339#section-5.6 spec as the hrs time offset is not 2 digits. Closing this issue.

@jababda jababda closed this as completed Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants