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

ParseDefinitions not supported 'Array' yet. #299

Closed
2BAB opened this issue Feb 12, 2019 · 3 comments
Closed

ParseDefinitions not supported 'Array' yet. #299

2BAB opened this issue Feb 12, 2019 · 3 comments
Labels

Comments

@2BAB
Copy link

2BAB commented Feb 12, 2019

Describe the bug
I saw there is {array} definition in response annotation, but I don't know how to make an array as the parameter. Here is the example:

// @Param notification body push.ModelList true "balabala"

type ModelList []Model

Then I got: panic: ParseDefinitions not supported 'Array' yet.

To Reproduce
Steps to reproduce the behavior:

  1. Run swag init

Expected behavior
Support array in parameters annotation.

Your swag version
github.com/swaggo/gin-swagger v1.0.0
github.com/swaggo/swag v1.4.0

@1bazinga25
Copy link

type X struct {
  IDs []int64 
}

// @Param Message body api.X true "tips"
when I use swag init,I got this message in api difinition:Unknown Type:int64
so,I wonder if any solution for this question?
or, this is just my fault for body type which I want to define an array type.

@ubogdan
Copy link
Contributor

ubogdan commented Aug 8, 2019

Issue #299 supporting array of things is already fixed on #462.
Annotation
// @Param payload body web.TagList true "description"

package web

type TagList []Tag

// Tag example
type Tag struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Please get latest swagger and open an issue if still not working.

@ubogdan ubogdan closed this as completed Aug 8, 2019
@stanlyzoolo
Copy link

Hi, @ubogdan
I had the same issue today.

type Candidate struct {
	AccountId int64  `json:"account_id" validate:"required,numeric" example:"1,2,3"`
	Reason    string `json:"reason" validate:"required,oneof=test1 test2 test3" example:"test1"`
	Comment   string `json:"comment" example:"Abcd"`
}

type candidatesRequest struct {
	List []Candidate `json:"candidates" validate:"required,min=1,dive,required"` 
}

Param declared as

...
// @Param request body candidatesRequest true "Body"
// @Accept json
...

The request part in doc is empty
image

How can I fix it?

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

No branches or pull requests

5 participants