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

[Bug]: @example decorator fails to generate a proper example if nested models are used #3874

Closed
4 tasks done
dmytrol opened this issue Jul 17, 2024 · 1 comment · Fixed by #3875
Closed
4 tasks done
Assignees
Labels
bug Something isn't working needs-area

Comments

@dmytrol
Copy link

dmytrol commented Jul 17, 2024

Describe the bug

When the @example decorator is applied to a model property that references another model, the generated example is invalid

Reproduction

Declare the following models:

model A {
  name: string
}

model B {
  items: Array<A>
}

Apply the @example decorator to model B as follows:

@example(#{
  items: #[
    #{ name: "one" },
    #{ name: "two" }
  ]
})
model B {
  items: Array<A>
}

The generated example: section in the resultant YAML will look like:

example:
        items:
          - {}
          - {}

which isn't even valid YAML

Checklist

@dmytrol dmytrol added the bug Something isn't working label Jul 17, 2024
@timotheeguerin
Copy link
Member

Weird issue, will try to see about getting a hotfix for that as well

@timotheeguerin timotheeguerin self-assigned this Jul 17, 2024
github-merge-queue bot pushed a commit that referenced this issue Jul 17, 2024
fix #3874 (Examples not working with nested model in array)
fix #3872 (Examples not working when type is union)

Additionally found the following issues that this fix:
- not working when type was `unknown`
- not working with `Record`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-area
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants