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

Unexpected OpenAPI specification when using CollectionOf() + View() in Attribute #3562

Closed
neilogic1911 opened this issue Jul 19, 2024 · 1 comment · Fixed by #3567
Closed

Comments

@neilogic1911
Copy link

My API design requirement is to ensure that the elements are included under the data attribute in the response of ListElements:

{
  "pageInfo": {
    // Page information goes here...
  },
  "data": [
    // List of elements goes here...
  ]
}

The Element type have two views: default and tiny. When these views appear in CollectionOf, everything works fine if the tiny collection passed directly to the Result(). However, when the collection is part of an attibute the tiny view will be not work correctly.

demo repo

@raphael
Copy link
Member

raphael commented Jul 28, 2024

Thank you for the nice repro. This is fixed by #3567. Note that the explicit view should be defined on the collection, not on the result, i.e.:

		Result(func() {
			Attribute("data", CollectionOf(Element, func() {
				View("tiny")
			}))
		})

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

Successfully merging a pull request may close this issue.

2 participants