Giter Club home page Giter Club logo

ajv-oai's People

Contributors

amazing-gao avatar dependabot[bot] avatar javi11 avatar xvincentx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

javi11

ajv-oai's Issues

nullable is not supported

const Ajvoai = require('ajv-oai')
const ajvoai = new Ajvoai({ coerceTypes: false });
console.log( ajvoai.compile({ type: 'string', nullable: true })(null));

should return true, but returns false

OpenAPI v3.1 Support

Hey there, I help maintain two tools which use this package: Spectral and Prism.

Both are looking to update OAS support to OpenAPI v3.1, and to do that changes to this package will be required.

I'll be happy to help out, I just wanted to start the conversation somewhere. First and foremost, how do we go about supporting both OAS 3.0 and 3.1 in the same package, because there's some breaking changes in there.

Request: ability to use ajv-oai as an AJV plugin.

Hi,

I'm the author of fastify-openapi-glue which adds OpenAPI support to the Fastify webserver.
fastify-openapi-glue uses your ajv-oai to implement the additional types on AJV.

Currently I create a new AJV instance using ajv-oai and pass that to Fastify. (see https://github.com/seriousme/fastify-openapi-glue/blob/master/index.js#L50)
That works great (thanks for that !) but also means that I need to track changes in Fastify's config of AJV.

Fastify exposes a parameter 'ajv' (see https://www.fastify.io/docs/latest/Server/#ajv) to pass AJV plugins to the default AJV instance.

Now If I could pass ajv-oai as a plugin to AJV then I would not need to track changes in Fastify's AJV config anymore.

I checked other AJV plugins (e.g. https://github.com/luzlab/ajv-formats/blob/master/index.js) and the main difference is that AJV needs to be passed as a parameter.

Is it possible to add a plugin option to ajv-oai ?

I can write a PR.

Kind regards,
Hans

ajv peerDependency

Hi,

Thanks a lot for your work ;)
I found an incoherence between your github repo and what is published into npm registry. Indeed, in npm registry, ajv 6.x is declared as peerDependency but not in your code :(
https://www.npmjs.com/package/ajv-oai?activeTab=explore
I would like prefer using your code without this peerDependency declaration :D

Regards,

ajv-oai does not check type correctly

I would expect that ajv-oai and ajv return the same result for the following types.
I would also expect that nullable:false means null is not accepted.

versions

node_modules/ajv-oai/package.json: "version": "1.2.0"
node_modules/ajv/package.json: "version": "6.12.5"

code

const Ajv = require('ajv')
const ajv = new Ajv();
const Ajvoai = require('ajv-oai')
const ajvoai = new Ajvoai();

console.log(ajv.compile({ type: 'number' })("42"));
console.log(ajv.compile({ type: 'string' })(42));
console.log(ajv.compile({ type: 'string' })(null))

console.log(ajvoai.compile({ type: 'number' })("42"));
console.log(ajvoai.compile({ type: 'string' })(42));
console.log(ajvoai.compile({ type: 'string', })(null));
console.log(ajvoai.compile({ type: 'string', nullable: false })(null));

expected output

false
false
false
false
false
false
false

actual output

false
false
false
true
true
true
true

Does not fail on missing required field

When you specify a property as required, but omit it from the JSON it will not fail the validation. It should always fail on a missing required property.

Example

# Partial OpenAPI Schema
type: object
required:
  - foo
properties:
  foo:
    type: string
  bar:
    type: string
{
  "bar": "some value"
}

Validation using this OAS and JSON should fail but doesn't.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.