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

Switch to a supported OpenAPI validator. #430

Merged
merged 3 commits into from
Jul 11, 2024
Merged

Conversation

adk-swisstopo
Copy link
Member

This requires some changes to the spec and I still disabled some checks that would be too disruptive. See commits for details.

When updating the linter to something more recent, supported and more strict,
we uncovered the following errors:

```
Message :   $ref must not be placed next to any other properties
Rule    :   no-$ref-siblings
Path    :   components.schemas.itemBase.properties.properties.readOnly
Line    :   1097

Message :   $ref must not be placed next to any other properties
Rule    :   no-$ref-siblings
Path    :   components.schemas.itemBase.properties.stac_version.readOnly
Line    :   1100
```

The no-$ref-siblings rule is documented in https://docs.stoplight.io/docs/spectral/4dec24461f3af-open-api-rules#no-ref-siblings
We resolve this by moving the `readOnly` attribute into the component. This was
already done for `stac_version`. For `properties` we verified it is only used
in one place so it should be safe.
When updating the linter to something more recent, supported and stricter,
we uncovered the following error:

```
Message :   Schema of type string should use one of the following formats: binary, byte, crn, date, date-time, email, identifier, password, url, uuid
Rule    :   ibm-schema-type-format
Path    :   components.schemas.sha256
Line    :   665
```

The ibm-schema-type-format rule is documented in https://github.com/IBM/openapi-validator/blob/main/docs/ibm-cloud-rules.md#ibm-schema-type-format
We resolve this by changing the format from `digest` to `binary`. Additionnally,
we set `minLength` and `maxLength` to 64 as that's the lenght of a SHA-256 hash
expressed as hexadecimal.
We currently use IBM's OpenAPI validator 0.54.0 (released circa February 2022)
from an old unsupported Docker image. With this change we update to version
1.19.2 (released June 2024) based on a Docker image shipped by IBM itself.

There were many changes in the validator since. In particular, the ruleset has
stricter checks about naming conventions that are specific to IBM guidelines
and which we don't follow. Rather than updating our specs to comply with IBM
guidelines, we disable these specific checks.

We also remove the old .validaterc configuration file which the newer validator
is not able to parse anyway.
Copy link
Contributor

@boecklic boecklic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for looking into this and updating validation!

@adk-swisstopo adk-swisstopo merged commit 93fec14 into develop Jul 11, 2024
3 checks passed
@adk-swisstopo adk-swisstopo deleted the fix-PB-687-lint-spec branch July 11, 2024 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants