subeeshcbabu-zz / swagmock

Mock data generator for swagger api
MIT License
173 stars 38 forks source link

Add support for an x-format property #42

Open ajfisher opened 7 years ago

ajfisher commented 7 years ago

As chance.js is being used, the scope of the type of data that can be mocked is more than the "common" formats used informally by the swagger spec.

Rather than confuse this, I've used an extension to the property as x-format which can be used to provide format hinting.

For the moment this is limited to firstname and lastname which does the appropriate mapping to chance.js however this could be extended to deal with things like place data etc to comprise the wider set of data chance.js can create.

example property definition:


  person:
    type: object
    properties:
      id:
        type: string
        format: uuid
        description: UUIDv4 for the specific person
      email:
        type: string
        format: email
        description: email address for the person
      phone:
        type: string
        format: phone
      first_name:
        type: string
        x-format: firstname
        description: Name of the person
      last_name:
        type: string
        x-format: lastname
subeeshcbabu-zz commented 6 years ago

Thanks for the PR.