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

Options and other containers do not work with boxed types #751

Closed
gorgonblot opened this issue Nov 13, 2014 · 1 comment
Closed

Options and other containers do not work with boxed types #751

gorgonblot opened this issue Nov 13, 2014 · 1 comment

Comments

@gorgonblot
Copy link

Creating this issue in swagger-core based on related issue previously raised on spray-swagger (gettyimages/spray-swagger#31).

Consider the Scala example:
@apimodel(description = "Options of boxed types produces an Object ref instead of correct type")
case class BoxedTypesIssue31(stringSeq: Seq[String],
stringOpt: Option[String],
@(ApiModelProperty @field)(value = "Integers in a Sequence Box") intSeq: Seq[Int],
@(ApiModelProperty @field)(value = "Integer in an Option Box") intOpt: Option[Int],
justInt: Int)

Using swagger-core to generate the Swagger Spec results in:

{
"description": "Options of boxed types produces an Object ref instead of correct type",
"id": "BoxedTypesIssue31",
"properties": {
"intOpt": {
"$ref": "Object",
"description": "Integer in an Option Box"
},
"intSeq": {
"description": "Integers in a Sequence Box",
"items": {
"$ref": "Object"
},
"type": "array"
},
"justInt": {
"format": "int32",
"type": "integer"
},
"stringOpt": {
"type": "string"
},
"stringSeq": {
"items": {
"type": "string"
},
"type": "array"
}
}
}

The attributes justInt, stringOpt, and stringSeq are represented as desired.

The attributes intOpt and IntSeq are not. The boxed value is indicated as "$ref": "Object" instead of "type":"integer".

The desired Swagger Spec is:

{
"description": "Options of boxed types produces an Object ref instead of correct type, but can be overcome with dataType",
"id": "BoxedTypesIssue31WithDataType",
"properties": {
"intOpt": {
"description": "Integer in an Option Box",
"format": "int32",
"type": "integer"
},
"intSeq": {
"description": "Integers in a Sequence Box",
"items": {
"format": "int32",
"type": "integer"
},
"type": "array"
},
"justInt": {
"format": "int32",
"type": "integer"
},
"stringOpt": {
"type": "string"
},
"stringSeq": {
"items": {
"type": "string"
},
"type": "array"
}
}
}

I have some code that I will submit as a pull request that resolves this issue (to my satisfaction).

@fehguy
Copy link
Contributor

fehguy commented Nov 27, 2014

closing as PRs have been merged

@fehguy fehguy closed this as completed Nov 27, 2014
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

2 participants