-
-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query parameter part of request body in controller with MultiPartFile. …
…Fixes #1793
- Loading branch information
1 parent
3e8e84e
commit 7ad1bb7
Showing
7 changed files
with
269 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...ngdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app194/ArticleApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package test.org.springdoc.api.v30.app194; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springdoc.api.annotations.ParameterObject; | ||
|
||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestPart; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@Tag(name = "Article Api") | ||
@RestController("/article") | ||
public class ArticleApi { | ||
|
||
@GetMapping("query") | ||
public List<ArticleDto> query(@ParameterObject ArticleQueryCondition condition) { | ||
return new LinkedList<>(); | ||
} | ||
|
||
@PostMapping(value = "create", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) | ||
public ArticleDto create(@ParameterObject ArticleDto dto, @RequestPart MultipartFile file) { | ||
return new ArticleDto(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...ngdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app194/ArticleDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package test.org.springdoc.api.v30.app194; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
@Schema | ||
public class ArticleDto { | ||
@Schema(description = "title") | ||
private String title; | ||
|
||
@Schema(description = "content") | ||
private String content; | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public String getContent() { | ||
return content; | ||
} | ||
|
||
public void setContent(String content) { | ||
this.content = content; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...pi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app194/ArticleQueryCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package test.org.springdoc.api.v30.app194; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
@Schema | ||
public class ArticleQueryCondition { | ||
@Schema(description = "title") | ||
private String title; | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...napi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app194/SpringDocApp194Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* | ||
* * | ||
* * * | ||
* * * * Copyright 2019-2022 the original author or authors. | ||
* * * * | ||
* * * * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * * * you may not use this file except in compliance with the License. | ||
* * * * You may obtain a copy of the License at | ||
* * * * | ||
* * * * https://www.apache.org/licenses/LICENSE-2.0 | ||
* * * * | ||
* * * * Unless required by applicable law or agreed to in writing, software | ||
* * * * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * * * See the License for the specific language governing permissions and | ||
* * * * limitations under the License. | ||
* * * | ||
* * | ||
* | ||
*/ | ||
|
||
package test.org.springdoc.api.v30.app194; | ||
|
||
import test.org.springdoc.api.v30.AbstractSpringDocV30Test; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
@TestPropertySource(properties = "springdoc.default-support-form-data=false") | ||
public class SpringDocApp194Test extends AbstractSpringDocV30Test { | ||
|
||
@SpringBootApplication | ||
static class SpringDocTestApp {} | ||
|
||
} |
127 changes: 127 additions & 0 deletions
127
springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app194.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
{ | ||
"openapi": "3.0.1", | ||
"info": { | ||
"title": "OpenAPI definition", | ||
"version": "v0" | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "http://localhost", | ||
"description": "Generated server url" | ||
} | ||
], | ||
"paths": { | ||
"/create": { | ||
"post": { | ||
"tags": [ | ||
"Article Api" | ||
], | ||
"operationId": "create", | ||
"parameters": [ | ||
{ | ||
"name": "title", | ||
"in": "query", | ||
"description": "title", | ||
"required": false, | ||
"schema": { | ||
"type": "string", | ||
"description": "title" | ||
} | ||
}, | ||
{ | ||
"name": "content", | ||
"in": "query", | ||
"description": "content", | ||
"required": false, | ||
"schema": { | ||
"type": "string", | ||
"description": "content" | ||
} | ||
} | ||
], | ||
"requestBody": { | ||
"content": { | ||
"multipart/form-data": { | ||
"schema": { | ||
"required": [ | ||
"file" | ||
], | ||
"type": "object", | ||
"properties": { | ||
"file": { | ||
"type": "string", | ||
"format": "binary" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"content": { | ||
"*/*": { | ||
"schema": { | ||
"$ref": "#/components/schemas/ArticleDto" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/query": { | ||
"get": { | ||
"tags": [ | ||
"Article Api" | ||
], | ||
"operationId": "query", | ||
"parameters": [ | ||
{ | ||
"name": "title", | ||
"in": "query", | ||
"description": "title", | ||
"required": false, | ||
"schema": { | ||
"type": "string", | ||
"description": "title" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"content": { | ||
"*/*": { | ||
"schema": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/components/schemas/ArticleDto" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"ArticleDto": { | ||
"type": "object", | ||
"properties": { | ||
"title": { | ||
"type": "string", | ||
"description": "title" | ||
}, | ||
"content": { | ||
"type": "string", | ||
"description": "content" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |