-
-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2183 from uc4w6c/fix_DefaultFlatParamObject
fixed DefaultFlatParamObject to work with annotated parameters. Fixes…
- Loading branch information
Showing
5 changed files
with
190 additions
and
15 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
20 changes: 20 additions & 0 deletions
20
...ore/src/test/java/test/org/springdoc/api/v30/app204/DefaultFlatParamObjectController.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,20 @@ | ||
package test.org.springdoc.api.v30.app204; | ||
|
||
import org.springdoc.api.annotations.ParameterObject; | ||
|
||
import org.springframework.data.domain.Sort; | ||
import org.springframework.data.domain.Sort.Direction; | ||
import org.springframework.data.web.SortDefault; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class DefaultFlatParamObjectController { | ||
@GetMapping("/test1") | ||
public String test1(@RequestParam String email, @Validated Person person, @SortDefault("name") @ParameterObject Sort sort) { | ||
return null; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app204/Person.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,33 @@ | ||
package test.org.springdoc.api.v30.app204; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
import javax.validation.constraints.Size; | ||
|
||
public class Person { | ||
private long id; | ||
|
||
private String firstName; | ||
|
||
@NotBlank | ||
@Size(max = 10) | ||
private String lastName; | ||
|
||
public Person(long id, String firstName, String lastName) { | ||
this.id = id; | ||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
public String getLastName() { | ||
return lastName; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...napi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app204/SpringDocApp204Test.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,43 @@ | ||
/* | ||
* | ||
* * | ||
* * * | ||
* * * * Copyright 2019-2023 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.app204; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springdoc.core.Constants; | ||
import test.org.springdoc.api.v30.AbstractSpringDocV30Test; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@TestPropertySource(properties = { "springdoc.default-flat-param-object=true" }) | ||
public class SpringDocApp204Test extends AbstractSpringDocV30Test { | ||
@SpringBootApplication | ||
static class SpringDocTestApp {} | ||
} |
88 changes: 88 additions & 0 deletions
88
springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app204.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,88 @@ | ||
{ | ||
"openapi": "3.0.1", | ||
"info": { | ||
"title": "OpenAPI definition", | ||
"version": "v0" | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "http://localhost", | ||
"description": "Generated server url" | ||
} | ||
], | ||
"paths": { | ||
"/test1": { | ||
"get": { | ||
"tags": [ | ||
"default-flat-param-object-controller" | ||
], | ||
"operationId": "test1", | ||
"parameters": [ | ||
{ | ||
"name": "email", | ||
"in": "query", | ||
"required": true, | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "id", | ||
"in": "query", | ||
"required": false, | ||
"schema": { | ||
"type": "integer", | ||
"format": "int64" | ||
} | ||
}, | ||
{ | ||
"name": "firstName", | ||
"in": "query", | ||
"required": false, | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "lastName", | ||
"in": "query", | ||
"required": true, | ||
"schema": { | ||
"maxLength": 10, | ||
"minLength": 0, | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"name": "sort", | ||
"in": "query", | ||
"description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", | ||
"required": false, | ||
"schema": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"default": [ | ||
"name,ASC" | ||
] | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"content": { | ||
"*/*": { | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": {} | ||
} |