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

x-faker: date.* does not work if a property is nullable #2309

Open
andrekeoz opened this issue Jun 16, 2023 · 1 comment
Open

x-faker: date.* does not work if a property is nullable #2309

andrekeoz opened this issue Jun 16, 2023 · 1 comment

Comments

@andrekeoz
Copy link

andrekeoz commented Jun 16, 2023

If i set a property to nullable, the faker provider for dates does not work.

/test:
    get:
        responses:
            '200':
                content:
                    application/json:
                        schema:
                            type: object
                            additionalProperties: false
                            properties:
                                test:
                                    type: string
                                    x-faker: date.future
                                    format: date-time
                                    nullable: true

Current Behavior

The faker provider does not generate a value

{
   "test" : "1950-04-11T00:00:00.0Z"
}

Expected Behavior

That the the returned date is in the future

{
   "test" : "2024-04-08T00:00:00.0Z"
}

Possible Workaround/Solution

remove nullable from property

Steps to Reproduce

/test:
    get:
        responses:
            '200':
                content:
                    application/json:
                        schema:
                            type: object
                            additionalProperties: false
                            properties:
                                test:
                                    type: string
                                    x-faker: date.future
                                    format: date-time
                                    nullable: true

Environment

  • Version used: @stoplight/[email protected]
  • Environment name and version (e.g. Chrome 39, node.js 5.4): node v16.19.1, curl
@akluthe
Copy link

akluthe commented Aug 22, 2023

Just bumped into this one too. Any other workarounds found maybe by using fake creatively?

x-faker:
     fake: '{{}}'

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

No branches or pull requests

4 participants