Skip to content

Commit

Permalink
Testing pattern with specifying Schema in response headers.
Browse files Browse the repository at this point in the history
Confirm that setting Header annotations specified in the Schema attribute in ApiResponse's headers attribute does not result in errors.
  • Loading branch information
footaku committed Apr 4, 2024
1 parent 679fb4d commit 7e78f05
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 0 deletions.
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!";
}
}
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 {}

}
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": {}
}

0 comments on commit 7e78f05

Please sign in to comment.