Giter Site home page Giter Site logo

Comments (6)

WaleedAshraf avatar WaleedAshraf commented on May 28, 2024 1

@jkuehnemundt @oBJIADo I'm working on PR to fix these issues. These will be addressed in the coming major version.

from asyncapi-validator.

WaleedAshraf avatar WaleedAshraf commented on May 28, 2024

Hi, @jkuehnemundt . I'll take a look at this.

Meanwhile, can you provide more details?

What exact error are you getting?
What version of the asyncapi-validator are you using?
What version of AsyncAPI are you using?

from asyncapi-validator.

WaleedAshraf avatar WaleedAshraf commented on May 28, 2024

@jkuehnemundt I'd suggest that for now you use minimum and maximum fields. That's how AsyncAPI adds supports for int32 and other openapi formats. See here: https://github.com/openapi-contrib/openapi-schema-to-json-schema/blob/master/lib/converters/schema.js#L182

from asyncapi-validator.

oBJIADo avatar oBJIADo commented on May 28, 2024

Hi @WaleedAshraf.
I had the same problem, but for int64. And I can provide a little more information about the error.

  • Version of the asyncapi-validator: 2.5.0

  • The error I had:

(node:24384) UnhandledPromiseRejectionWarning: Error: unknown format "int64" is used in schema at path "#/properties/phone"
    at Object.generate_format [as code] (/node_modules/ajv/lib/dotjs/format.js:69:15)
    at Object.generate_validate [as validate] (/node_modules/ajv/lib/dotjs/validate.js:374:35)
    at Object.generate_properties [as code] (/node_modules/ajv/lib/dotjs/properties.js:201:26)
    at generate_validate (/node_modules/ajv/lib/dotjs/validate.js:374:35)
    at localCompile (/node_modules/ajv/lib/compile/index.js:88:22)
    at Ajv.compile (/node_modules/ajv/lib/compile/index.js:55:13)
    at Ajv._compile (/node_modules/ajv/lib/ajv.js:348:27)
    at Ajv.compile (/node_modules/ajv/lib/ajv.js:114:37)
    at MessageValidator.validate (/node_modules/asyncapi-validator/src/MessageValidator.js:58:33)
    at /asyncApiValidation.js:5:15
  • Api from your example with the new one field:
asyncapi: 2.0.0

info:
  title: User Events
  version: 1.0.0

channels:
  user-events:
    description: user related events
    publish:
      message:
        name: UserDeletedMessage
        x-custom-key: UserDeleted
        payload:
          type: object
          properties:
            userEmail:
              type: string
            userId:
              type: string
            phone:
              type: integer
              format: int64
              description: User phone
  • The code I use:
const AsyncApiValidator = require('asyncapi-validator')

// validate 'UserDeleted' on channel 'user-events' with operation 'publish'
AsyncApiValidator.fromSource('./api.yml', {msgIdentifier: 'x-custom-key'}).then(validator => {
    validator.validate('UserDeleted', {
        userId: '123456789',
        userEmail: '[email protected]',
        phone: 123456789
    }, 'user-events', 'publish')
});

from asyncapi-validator.

WaleedAshraf avatar WaleedAshraf commented on May 28, 2024

Can you test against this branch and see if it address your concern.
https://github.com/WaleedAshraf/asyncapi-validator/tree/v3

from asyncapi-validator.

WaleedAshraf avatar WaleedAshraf commented on May 28, 2024

Fixed in v3: https://github.com/WaleedAshraf/asyncapi-validator/releases/tag/v3.0.0

from asyncapi-validator.

Related Issues (20)

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.