Skip to content

Faker: generate UUID for uuid4 type #2703

@WilliamDEdwards

Description

@WilliamDEdwards

Stoplight generates a UUID when a property format is set to uuid. For example:

{"title":"Uuid","type":"string","format":"uuid"}

Proposal: do the same when format is uuid4.

Reason: Pydantic, a commonly used library in the Python ecosystem, uses that notation for UUIDs.

At the moment, Stoplight (or actually, json-schema-faker) is generating a string for my UUID fields, as it does not know about the uuid4 format. (FWIW: "format is an open value, so you can use any formats, even not those defined by the OpenAPI Specification" (https://swagger.io/docs/specification/v3_0/data-models/data-types/))

I could of course work around this by setting x-faker (as instructed on https://docs.stoplight.io/docs/prism/9528b5a8272c0-dynamic-response-generation-with-faker#how-it-works), but as its value is specified to the JavaScript library (datatype.uuid), that's doesn't belong in a general-purpose OpenAPI spec.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions