OAS 3 paramType = "body" not working. springfox-boot-starter:3.0.0
See original GitHub issue@PostMapping("/create")
@HystrixCommand(commandKey = "Create project")
@ResponseStatus(HttpStatus.CREATED)
@ApiOperation(notes = "Создаёт папки проекта на Dropbox и регистрирует в хранилище", value = "Создать проект", consumes = "application/json", tags = {"project", })
@ApiResponses(
value = {
@ApiResponse(code = 201, message = "Операция выполнена успешна."),
@ApiResponse(code = 409, message = "Папки проекта уже существуют. Не удалось создать."),
@ApiResponse(code = 403, message = "Ошибка авторизации."),
@ApiResponse(code = 404, message = "Запрошенный ресурс не существует."),
})
@ApiImplicitParams(
value = {
@ApiImplicitParam(name = "body", paramType = "body", dataTypeClass = ProjectName.class, required = true, value = "JSON объект с именем проекта и его транслитом на аглийский."),
@ApiImplicitParam(name = "temp", paramType = "query", dataTypeClass = Long.class, required = true, value = "temp")
})
public ResponseEntity<Void> createProject(@RequestBody ProjectName projectName) {
return ResponseEntity
.status(service.createProject(projectName))
.build();
}
generated output
"parameters": [
{
"name": "temp",
"in": "query",
"description": "temp",
"required": true,
"style": "form",
"allowReserved": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProjectName"
}
}
}
}
if i change type from body
to query
that working. But i need in:"body"
@ApiImplicitParams(
value = {
@ApiImplicitParam(name = "body", paramType = "query", dataTypeClass = ProjectName.class, required = true, value = "JSON объект с именем проекта и его транслитом на аглийский."),
@ApiImplicitParam(name = "temp", paramType = "query", dataTypeClass = Long.class, required = true, value = "temp")
})
"parameters": [
{
"name": "body",
"in": "query",
"description": "JSON объект с именем проекта и его транслитом на аглийский.",
"required": true,
"style": "form",
"allowReserved": true,
"schema": {
"$ref": "#/components/schemas/ProjectName"
}
},
{
"name": "temp",
"in": "query",
"description": "temp",
"required": true,
"style": "form",
"allowReserved": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProjectName"
}
}
}
},
bean
@Bean
public Docket openApi(TypeResolver typeResolver){
return new Docket(DocumentationType.OAS_30)
.useDefaultResponseMessages(false)
.securityContexts(Lists.newArrayList(securityContext()))
.securitySchemes(Lists.newArrayList(apiKey()))
.select()
.apis(RequestHandlerSelectors.basePackage("ru.trmedia.trportal.admin.web.rest"))
.build()
.additionalModels(
typeResolver.resolve(ProjectName.class)
)
.apiInfo(new ApiInfoBuilder().version("1.0").title("Admin API").description("Documentation Admin API v1.0").build())
.tags(
new Tag("project", "Операции с проектом")
);
}
model ( if i change model class to Long, still not working)
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "Имя проекта и его транслит на английский", value = "ProjectName")
public class ProjectName {
@ApiModelProperty(value = "имя проекта на латиннице, прим.: Магнит")
private String projectName;
@ApiModelProperty(value = "имя проекта на латиннице, прим.: Magnet")
private String projectNameTranslit;
}
maven
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
try adding “dataType=ProjectName”