Swagger Editor multiple parameters in body
By : user3853342
Date : March 29 2020, 07:55 AM
hop of those help? I'm not sure to understand your question... If you are trying to define more than one body parameter for one operation, you can't. As explained in swagger specification: code :
swagger: '2.0'
info:
version: "0.0.1"
title: Todo App
host: localhost:3000
schemes:
- http
- https
consumes:
- application/json
produces:
- application/x-www-form-urlencoded
basePath: /
paths:
# This is a path endpoint. Change it.
/tasks:
post:
description: |
Add 'Task' object.
parameters:
- name: task
in: body
description: task object
required: true
schema:
$ref: '#/definitions/Task'
responses:
200:
description: Successful response
schema:
title: Return String
type: string
example: "Task added succesfully"
500:
description: Error
schema:
type: string
example: "Could not add Task"
definitions:
Task:
description: Task object
properties:
name:
type: string
description: task object name
description:
type: string
description: task description
required:
- name
- description
|
Change the parameters in body request of a method in Swagger
By : adam prakash
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further If you're objects usually have a one to one mapping for example, InputParam => InputParamView and ReturnObject => ReturnObjectView then its very simple to solve this problem. All you need to do is to set up alternate type rules in your docket. code :
docket
.directModelSubstitute(InputParam.class, InputParamView.class)
.directModelSubstitute(ReturnObject.class, ReturnObjectView.class)
|
Swagger POST/PUT body parameters not passing to my controller
By : Gabriel Ben-harosh H
Date : March 29 2020, 07:55 AM
I wish this helpful for you My simple swagger API documentation. parameters not passing to my controller while performing post and put operations.(Get and Delete operations performs fine) , Blunder: "consumes": [ "application/x-www-form-urlencoded" ],
|
Swagger parameters in query and/or body
By : Craig Wallen
Date : March 29 2020, 07:55 AM
Hope this helps You'll need to define both query parameters and body parameters but mark all of them as optional. Use the operation description to explain that the client can send the parameters in either query string or body. code :
swagger: '2.0'
...
paths:
/foo:
post:
consumes:
- application/json
parameters:
- in: query
name: param1
type: string
required: false
- in: query
name: param2
type: string
required: false
- in: body
name: body
required: false
schema:
type: object
properties:
param1:
type: string
param2:
type: string
openapi: 3.0.0
...
paths:
/foo:
post:
parameters:
# This expands into ?param1=value1¶m2=value2&...
- in: query
name: parameters
required: false
schema:
$ref: '#/components/schemas/Parameters'
style: form
explode: true
requestBody:
required: false
content:
application/json:
schema:
$ref: '#/components/schemas/Parameters'
responses:
'200':
description: OK
components:
schemas:
Parameters:
type: object
properties:
param1:
type: string
param2:
type: string
|
Swagger example post body - how to show JSON Body- Swagger-annotations
By : windsonho
Date : March 29 2020, 07:55 AM
will help you If changing from String to a concrete object is not okay (although that's what I would recommend you to do since it's cleaner), you can try using @ApiImplicitParams (check out their documentation) code :
@ApiOperation(notes = "example" value = "/example", consumes = ".." , method= "..")
@ApiImplicitParams({
@ApiImplicitParam(name = "Object", value = "Object to be created", required = true, dataType = "your.package.BodyClass", paramType = "body")
})
@RequestMapping(name = "xxx" value ="/hello" ..)
@ApiResponses(..)
public @ResponseBody String getXXX (@Apiparam(name="JSONrequest", required = true) @RequestBody String JSONrequest){
}
|