ajv-validator / ajv-validator/ajv

Why does AJV contain its own types for JSON Schema instead of using an external package

Aberta
#2,312 1 comentário 3 reações 0 responsáveis Ver no GitHub
typescript
Linguagem predominante
TypeScript
Estrelas
14.8k
Forks
1k
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

**What version of Ajv are you using? Does the issue happen if you use the latest version?**

8.12.0

**Your typescript code**

```typescript
import type { JSONSchemaType } from "ajv";
```

**Describe the change that should be made to address the issue?**

Hello everyone! First of all, thanks to all the maintainers for your contribution!

I would just like to know why ajv contains its own definitions for JSON Schema. JSON Schema is a Standard, so its types should be the same in different applications. Common types would help to glue different packages. It may look like this:

```typescript
import Ajv from "ajv";
import schemaBuilder from "some-schema-builder-package";

import type { JSONSchemaType } from "some-common-schema-package";

const ajv = new Ajv();

const mySchema: JSONSchemaType = schemaBuilder(/* ... */);
const validate = ajv.compile(mySchema);
```

But now I have to redefine package typings to make types from ajv and different packages "match" to each other.

On the [json-schema.org website](https://json-schema.org/implementations.html#from-code) I found [typescript-json-schema package](https://github.com/YousefED/typescript-json-schema/blob/v0.59.0/package.json#L44), which imports types from [@types/json-schema](https://www.npmjs.com/package/@types/json-schema) package.

Why doesn't ajv use `@types/json-schema` package?

**Are you going to resolve the issue?**

Apparently, this is an ideological issue, so I’m not able to solve it.

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.