Redocly / Redocly/redocly-cli

Linter problem with multipleOf (no-invalid-schema-examples rule)

Open
#751 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

governance p3 Type: Bug
Dominant language
TypeScript
Stars
1.5k
Forks
228
Avg merge
1d 14h
Merged PRs (30d)
48

Description

Describe the bug
The linter incorrectly flags a problem with a multipleOf that is valid in the rule no-invalid-schema-examples

To Reproduce
Create an openapi definition and create a property like this:

    foo:
        format: float
        multipleOf: 0.1
        type: number
        example: 98.8

Expected behavior
This shouldn't cause any issue as 98.8 is a multipleOf 0.1

**Problem **
The linter gives this error message:

[1] specs\internal.json:20644:36 at #/components/schemas/queue-getStatus-v1-Response-mPayload/properties/dQueueSlapercent/example

Example value must conform to the schema: must be multiple of 0.1.

20642 |     "multipleOf": 0.1,
20643 |     "type": "number",
20644 |     "example": 98.8
20645 | },
20646 | "a_objQueuemember": {

referenced from specs\internal.json:20639:41

Error was generated by the no-invalid-schema-examples rule.

OpenAPI definition
3.0.3

Redocly Version(s)
npx @redocly/openapi-cli --version
1.0.0-beta.95

Node.js Version(s)
npm -v
8.13.1

Thanks in advance

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The affected entry point is the no-invalid-schema-examples rule; begin by reproducing the OpenAPI 3.0.3 example with multipleOf: 0.1 and example: 98.8. Done means this valid example is no longer reported by the rule, with behavior checked against the shown linter output.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, openapi, typescript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.