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

Springfox-UI not showing custom examples #3163

Closed
SledgeHammer01 opened this issue Oct 25, 2019 · 4 comments
Closed

Springfox-UI not showing custom examples #3163

SledgeHammer01 opened this issue Oct 25, 2019 · 4 comments
Labels

Comments

@SledgeHammer01
Copy link

springfox-swagger2 2.9.2
springfox-swagger-ui 2.9.2

Controller method looks like this:

@ApiOperation(value="Creates a customer.")
@ApiResponses(value={
	@ApiResponse(code=200, message="OK"),
	@ApiResponse(code=401, message="Unauthorized")
})
@PreAuthorize("#oauth2.hasScope('Any')")
@RequestMapping(value="/customers", method=RequestMethod.POST, consumes="application/json", produces="application/json")
public Customer createCustomer(@ApiParam(value="New customer to create.", required=true, examples=@Example(value=@ExampleProperty(mediaType="application/json", value = "{'firstName': 'John', id: 0, lastName='Smith'}"))) @RequestBody Customer customer) {
	return customer;
}

When I look at the swagger page, the example is shown as:

{ "firstName": "string", "id": 0, "lastName": "string" }

I've also tried " instead of ' in the example json... same issue. Also tried ApiImplicitParam... same issue.

.json looks like this:

  "post": {
    "tags": [ "Customer" ],
    "summary": "Creates a customer.",
    "operationId": "createCustomerUsingPOST",
    "consumes": [ "application/json" ],
    "produces": [ "application/json" ],
    "parameters": [
      {
        "in": "body",
        "name": "customer",
        "description": "New customer to create.",
        "required": true,
        "schema": { "$ref": "#/definitions/Customer" },
        "x-examples": { "application/json": "{'firstName': 'John', id: 0, lastName='Smith'}" }
      }
    ],

NOTE: This is on the "Example Value" tab... the "Model" tab shows the values from the model specified with @ApiModelProperty(notes="Id of the customer.", required=true, value="1").

@SledgeHammer01
Copy link
Author

FYI, also have the same issue on @ApiResponse examples not getting rendered.

@ogerardin
Copy link
Contributor

Duplicate of #3037 ?

@stale
Copy link

stale bot commented Jun 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 24, 2020
@stale
Copy link

stale bot commented Jul 8, 2020

This issue has been automatically closed because it has not had recent activity. Please re-open a new issue if this is still an issue.

@stale stale bot closed this as completed Jul 8, 2020
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

2 participants