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

Override dataType to be "array of some specific model" #4050

Closed
2 tasks done
salomvary opened this issue Jan 30, 2023 · 1 comment
Closed
2 tasks done

Override dataType to be "array of some specific model" #4050

salomvary opened this issue Jan 30, 2023 · 1 comment

Comments

@salomvary
Copy link

Please take the time to search the repository, if your question has already been asked or answered.

  • What version of the library are you using? 3.0.0

What kind of issue is this?

  • Question. Is this a question about how to do a certain thing?

Hey folks, I've tried answering this question by looking at the documentation, source code and examples - without success.

Given a property of arbitrary actual java type (String in my case), is there a way to document this as an array of some specific model? (Eg. java.util.List<com.example.Pet>).

  @ApiModelProperty(
      dataType = "List[Pet]"
  )
  private String pets;

I've tried to put various things into dataType but nothing resulted in returning something like this in the api docs JSON:

"pets":{
   "type":"array",
   "items":{"$ref":"#/components/schemas/Pet"}
}

Is there a way to accomplish this? Thanks!

@salomvary
Copy link
Author

This StackOverflow answer was helpful: https://stackoverflow.com/a/44165801/759162

The solution is dataType = "[Lcom.example.Pet;".

I wish there was a nicer way, or this was documented somewhere.

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

No branches or pull requests

1 participant