forked from springdoc/springdoc-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing pattern with specifying Schema in response headers.
Confirm that setting Header annotations specified in the Schema attribute in ApiResponse's headers attribute does not result in errors.
- Loading branch information
Showing
3 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...i-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app218/HelloController.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,63 @@ | ||
/* | ||
* | ||
* * | ||
* * * | ||
* * * * Copyright 2019-2024 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.app218; | ||
|
||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.headers.Header; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.net.URI; | ||
|
||
|
||
@RestController | ||
@RequestMapping("/") | ||
public class HelloController { | ||
|
||
@Operation( | ||
summary = "Summary", | ||
description = "This is description.", | ||
tags = {"Sample"}, | ||
responses = { | ||
@ApiResponse( | ||
responseCode = "201", | ||
description = "201 (Created)", | ||
headers = | ||
@Header( | ||
name = HttpHeaders.LOCATION, | ||
description = "Sample endpoint", | ||
schema = @Schema(implementation = URI.class) | ||
) | ||
) | ||
} | ||
) | ||
@GetMapping | ||
public String get() { | ||
return "Hello World!"; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...arter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app218/SpringDocApp218Test.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-2024 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.app218; | ||
|
||
import org.springdoc.core.customizers.SpecPropertiesCustomizer; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import test.org.springdoc.api.v30.AbstractSpringDocV30Test; | ||
|
||
/** | ||
* <p> | ||
* A test for {@link SpecPropertiesCustomizer} | ||
*/ | ||
@SpringBootTest | ||
public class SpringDocApp218Test extends AbstractSpringDocV30Test { | ||
|
||
@SpringBootApplication | ||
static class SpringDocTestApp {} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app218.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,48 @@ | ||
{ | ||
"openapi": "3.0.1", | ||
"info": { | ||
"title": "OpenAPI definition", | ||
"version": "v0" | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "http://localhost", | ||
"description": "Generated server url" | ||
} | ||
], | ||
"paths": { | ||
"/": { | ||
"get": { | ||
"tags": [ | ||
"Sample" | ||
], | ||
"summary": "Summary", | ||
"description": "This is description.", | ||
"operationId": "get", | ||
"responses": { | ||
"201": { | ||
"description": "201 (Created)", | ||
"headers": { | ||
"Location": { | ||
"description": "Sample endpoint", | ||
"style": "simple", | ||
"schema": { | ||
"type": "string", | ||
"format": "uri" | ||
} | ||
} | ||
}, | ||
"content": { | ||
"*/*": { | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": {} | ||
} |