loopbackio / loopbackio/loopback-next

bug: ajv example validation

Open
#9,308 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.1k
Forks
1.1k
Avg merge
2d 21h
Merged PRs (30d)
27

Description

### Describe the bug

Steps to reproduce

```bash
git clone https://github.com/mosoriob/loopback-next.git
cd loopback-next/
cd sandbox/validation-ajv
npm install
npm test
```

## Current Behavior

The test fail with error:

```
Request POST /pets failed with status code 500. Error: strict mode: unknown keyword: "example"
```

## Link to reproduction sandbox

https://github.com/mosoriob/loopback-next.git

## More details

The API was generated using `lb4 openapi`

```
$ lb4 openapi pet.yaml
Loading pet.yaml...
? Select controllers and/or service proxies to be generated: OpenApiController
create src/models/pet.model.ts
create src/models/new-pet.model.ts
create src/models/error.model.ts
create src/controllers/open-api.controller.ts
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.

added 38 packages, and audited 609 packages in 10s

80 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities
```

### Logs

_No response_

### Additional information

Similar to: https://github.com/loopbackio/loopback-next/issues/4939

### Reproduction

https://github.com/mosoriob/loopback-next.git

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

Start in the sandbox/validation-ajv reproduction and run npm install followed by npm test to confirm the strict-mode error for the example keyword. Trace the API generated by lb4 openapi and identify why validation rejects that keyword; done means the reproduction test no longer fails with the unknown-keyword error.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, openapi, typescript
Domain
api, backend, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.