Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using uuid format in parametesr #16

Open
sah4ez opened this issue Dec 11, 2018 · 3 comments
Open

Using uuid format in parametesr #16

sah4ez opened this issue Dec 11, 2018 · 3 comments

Comments

@sah4ez
Copy link

sah4ez commented Dec 11, 2018

In my specification I using parameters:

        - in: header
          name: My-Header
          schema:
            type: string
            format: uuid

And for this format I got an error:

$ sudo oatts generate -s ./openapi.yaml -w ./tests/
Error: unknown generator for "uuid" in /
    at generate (/usr/local/lib/node_modules/oatts/node_modules/json-schema-faker/lib/jsf.js:74:13)
    at Parameter.getSample (/usr/local/lib/node_modules/oatts/node_modules/sway/lib/types/parameter.js:94:39)
    at /usr/local/lib/node_modules/oatts/lib/process.js:275:90
    at Array.forEach (<anonymous>)
    at processParams (/usr/local/lib/node_modules/oatts/lib/process.js:259:24)
    at /usr/local/lib/node_modules/oatts/lib/process.js:202:22
    at Array.forEach (<anonymous>)
    at processTransactions (/usr/local/lib/node_modules/oatts/lib/process.js:196:29)
    at /usr/local/lib/node_modules/oat
@noahdietz
Copy link
Collaborator

noahdietz commented Dec 19, 2018

Hi there, thanks for using oatts.

This is because the uuid format is not part of the OAS schema and as such, needs to be registered with a custom type generator on sway in order to fake the params using this format.

This should be an easy thing to add to oatts, just need to expose an option to supply the map of custom generators, then invoke the sway API call to register them with the API object.

Do you have any interest in supplying a PR for this?

@Uzlopak
Copy link
Contributor

Uzlopak commented May 25, 2019

@noahdietz
Like this, Bro? #20

@Uzlopak
Copy link
Contributor

Uzlopak commented May 25, 2019

So for uuid I guess you would add to the options of oatts

{
  customFormats: {
    'uuid': function (value, callback) {
        callback(/[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(value));
    }
  },
  customFormatGenerators: {
    'uuid': function (value) {
        return '550e8400-e29b-11d4-a716-446655440000';
    }
  }
}

Not tested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants