pactumjs / pactum

REST API Testing Tool for all levels in a Test Pyramid
https://pactumjs.github.io
MIT License
545 stars 52 forks source link

Feature Request: External JSON schema #74

Closed emfomy closed 3 years ago

emfomy commented 3 years ago

Is your feature request related to a problem? Please describe. I want to use external JSON schema provided in @exodus/schemasafe

Describe the solution you'd like Please add an optional argument for external schemas to expectJsonSchema and jsonSchema methods.

Describe alternatives you've considered Or maybe add a global setting for external schemas.

ASaiAnudeep commented 3 years ago

PactumJS (v3.0.18) now supports passing custom options to json schema validations.

Syntax
expectJsonSchema({ schema }, { options });
Example
await pactum.spec()
  .get('api/get')
  .expectJsonSchema(
    {
      type: 'object',
      properties: {
        method: {
          type: 'string',
          format: 'only-get'
        }
      }
    },
    {
      formats: {
        'only-get': /^GET$/
      }
    }
  );