forked from loafle/openapi-generator-original
[spring] reactive: fix Content-Type (#16228)
* don't set content-type to client's value * revert manual sample change * better fix * generate samples * cover 3rd case * add new test endpoint
This commit is contained in:
@@ -38,6 +38,7 @@ public class ExampleGenerator {
|
||||
|
||||
private static final String EXAMPLE = "example";
|
||||
private static final String CONTENT_TYPE = "contentType";
|
||||
private static final String GENERATED_CONTENT_TYPE = "generatedContentType";
|
||||
private static final String OUTPUT = "output";
|
||||
private static final String NONE = "none";
|
||||
private static final String URL = "url";
|
||||
@@ -112,12 +113,14 @@ public class ExampleGenerator {
|
||||
String example = Json.pretty(resolvePropertyToExample("", mediaType, property, processedModels));
|
||||
if (example != null) {
|
||||
kv.put(EXAMPLE, example);
|
||||
kv.put(GENERATED_CONTENT_TYPE, MIME_TYPE_JSON);
|
||||
output.add(kv);
|
||||
}
|
||||
} else if (property != null && mediaType.startsWith(MIME_TYPE_XML)) {
|
||||
String example = new XmlExampleGenerator(this.examples).toXml(property);
|
||||
if (example != null) {
|
||||
kv.put(EXAMPLE, example);
|
||||
kv.put(GENERATED_CONTENT_TYPE, MIME_TYPE_XML);
|
||||
output.add(kv);
|
||||
}
|
||||
}
|
||||
@@ -157,6 +160,7 @@ public class ExampleGenerator {
|
||||
|
||||
if (example != null) {
|
||||
kv.put(EXAMPLE, example);
|
||||
kv.put(GENERATED_CONTENT_TYPE, MIME_TYPE_JSON);
|
||||
output.add(kv);
|
||||
}
|
||||
}
|
||||
@@ -165,6 +169,7 @@ public class ExampleGenerator {
|
||||
String example = new XmlExampleGenerator(this.examples).toXml(schema, 0, Collections.emptySet());
|
||||
if (example != null) {
|
||||
kv.put(EXAMPLE, example);
|
||||
kv.put(GENERATED_CONTENT_TYPE, MIME_TYPE_XML);
|
||||
output.add(kv);
|
||||
}
|
||||
} else {
|
||||
@@ -201,6 +206,7 @@ public class ExampleGenerator {
|
||||
kv.put(CONTENT_TYPE, mediaType);
|
||||
if ((mediaType.startsWith(MIME_TYPE_JSON) || mediaType.contains("*/*"))) {
|
||||
kv.put(EXAMPLE, Json.pretty(example));
|
||||
kv.put(GENERATED_CONTENT_TYPE, MIME_TYPE_JSON);
|
||||
output.add(kv);
|
||||
} else if (mediaType.startsWith(MIME_TYPE_XML)) {
|
||||
// TODO
|
||||
|
||||
@@ -39,7 +39,7 @@ Mono<Void> result = Mono.empty();
|
||||
{{/-first}}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("{{{contentType}}}"))) {
|
||||
String exampleString = {{>exampleString}};
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("{{{generatedContentType}}}"), exampleString);
|
||||
break;
|
||||
}
|
||||
{{#-last}}
|
||||
|
||||
@@ -1008,6 +1008,20 @@ paths:
|
||||
responses:
|
||||
"200":
|
||||
description: Success
|
||||
/fake/response-with-example:
|
||||
get:
|
||||
tags:
|
||||
- fake
|
||||
description: This endpoint defines an example value for its response schema.
|
||||
operationId: testWithResultExample
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
example: 42
|
||||
type: integer
|
||||
description: Success
|
||||
/fake/test-query-parameters:
|
||||
put:
|
||||
tags:
|
||||
|
||||
@@ -343,4 +343,20 @@ public interface FakeApi {
|
||||
@RequestParam(value = "context", required = true) List<String> context
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@HttpExchange(
|
||||
method = "GET",
|
||||
value = "/fake/response-with-example",
|
||||
accept = "application/json"
|
||||
)
|
||||
Mono<ResponseEntity<Integer>> testWithResultExample(
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -339,4 +339,20 @@ public interface FakeApi {
|
||||
@RequestParam(value = "context", required = true) List<String> context
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@HttpExchange(
|
||||
method = "GET",
|
||||
value = "/fake/response-with-example",
|
||||
accept = "application/json"
|
||||
)
|
||||
ResponseEntity<Integer> testWithResultExample(
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -480,4 +480,30 @@ public interface FakeApi {
|
||||
@NotNull @Parameter(name = "context", description = "", required = true, in = ParameterIn.QUERY) @Valid @RequestParam(value = "context", required = true) List<String> context
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "testWithResultExample",
|
||||
description = "This endpoint defines an example value for its response schema.",
|
||||
tags = { "fake" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "Success", content = {
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Integer.class))
|
||||
})
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/fake/response-with-example",
|
||||
produces = "application/json"
|
||||
)
|
||||
ResponseEntity<Integer> testWithResultExample(
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -538,6 +538,34 @@ public interface FakeApi {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "testWithResultExample",
|
||||
description = "This endpoint defines an example value for its response schema.",
|
||||
tags = { "fake" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "Success", content = {
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Integer.class))
|
||||
})
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/fake/response-with-example",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
default ResponseEntity<Integer> testWithResultExample(
|
||||
|
||||
) {
|
||||
return getDelegate().testWithResultExample();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -318,6 +318,27 @@ public interface FakeApiDelegate {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
* @see FakeApi#testWithResultExample
|
||||
*/
|
||||
default ResponseEntity<Integer> testWithResultExample() {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "42";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -1088,6 +1088,23 @@ paths:
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/response-with-example:
|
||||
get:
|
||||
description: This endpoint defines an example value for its response schema.
|
||||
operationId: testWithResultExample
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
example: 42
|
||||
type: integer
|
||||
description: Success
|
||||
tags:
|
||||
- fake
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/test-query-parameters:
|
||||
put:
|
||||
description: To test the collection format in query parameters
|
||||
|
||||
@@ -584,6 +584,44 @@ public interface FakeApi {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "testWithResultExample",
|
||||
description = "This endpoint defines an example value for its response schema.",
|
||||
tags = { "fake" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "Success", content = {
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Integer.class))
|
||||
})
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/fake/response-with-example",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
default ResponseEntity<Integer> testWithResultExample(
|
||||
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "42";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -1088,6 +1088,23 @@ paths:
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/response-with-example:
|
||||
get:
|
||||
description: This endpoint defines an example value for its response schema.
|
||||
operationId: testWithResultExample
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
example: 42
|
||||
type: integer
|
||||
description: Success
|
||||
tags:
|
||||
- fake
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/test-query-parameters:
|
||||
put:
|
||||
description: To test the collection format in query parameters
|
||||
|
||||
@@ -508,6 +508,32 @@ public interface FakeApi {
|
||||
) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "testWithResultExample",
|
||||
description = "This endpoint defines an example value for its response schema.",
|
||||
tags = { "fake" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "Success", content = {
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Integer.class))
|
||||
})
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/fake/response-with-example",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
ResponseEntity<Integer> testWithResultExample(
|
||||
|
||||
) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -578,6 +578,44 @@ public interface FakeApi {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@ApiOperation(
|
||||
tags = { "fake" },
|
||||
value = "",
|
||||
nickname = "testWithResultExample",
|
||||
notes = "This endpoint defines an example value for its response schema.",
|
||||
response = Integer.class
|
||||
)
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "Success", response = Integer.class)
|
||||
})
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/fake/response-with-example",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
default ResponseEntity<Integer> testWithResultExample(
|
||||
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "42";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -1088,6 +1088,23 @@ paths:
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/response-with-example:
|
||||
get:
|
||||
description: This endpoint defines an example value for its response schema.
|
||||
operationId: testWithResultExample
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
example: 42
|
||||
type: integer
|
||||
description: Success
|
||||
tags:
|
||||
- fake
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/test-query-parameters:
|
||||
put:
|
||||
description: To test the collection format in query parameters
|
||||
|
||||
@@ -578,6 +578,44 @@ public interface FakeApi {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@ApiOperation(
|
||||
tags = { "fake" },
|
||||
value = "",
|
||||
nickname = "testWithResultExample",
|
||||
notes = "This endpoint defines an example value for its response schema.",
|
||||
response = Integer.class
|
||||
)
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "Success", response = Integer.class)
|
||||
})
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/fake/response-with-example",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
default ResponseEntity<Integer> testWithResultExample(
|
||||
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "42";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -1088,6 +1088,23 @@ paths:
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/response-with-example:
|
||||
get:
|
||||
description: This endpoint defines an example value for its response schema.
|
||||
operationId: testWithResultExample
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
example: 42
|
||||
type: integer
|
||||
description: Success
|
||||
tags:
|
||||
- fake
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/test-query-parameters:
|
||||
put:
|
||||
description: To test the collection format in query parameters
|
||||
|
||||
@@ -532,6 +532,34 @@ public interface FakeApi {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@ApiOperation(
|
||||
tags = { "fake" },
|
||||
value = "",
|
||||
nickname = "testWithResultExample",
|
||||
notes = "This endpoint defines an example value for its response schema.",
|
||||
response = Integer.class
|
||||
)
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "Success", response = Integer.class)
|
||||
})
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/fake/response-with-example",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
default ResponseEntity<Integer> testWithResultExample(
|
||||
|
||||
) {
|
||||
return getDelegate().testWithResultExample();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -318,6 +318,27 @@ public interface FakeApiDelegate {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
* @see FakeApi#testWithResultExample
|
||||
*/
|
||||
default ResponseEntity<Integer> testWithResultExample() {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "42";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -1088,6 +1088,23 @@ paths:
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/response-with-example:
|
||||
get:
|
||||
description: This endpoint defines an example value for its response schema.
|
||||
operationId: testWithResultExample
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
example: 42
|
||||
type: integer
|
||||
description: Success
|
||||
tags:
|
||||
- fake
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/test-query-parameters:
|
||||
put:
|
||||
description: To test the collection format in query parameters
|
||||
|
||||
@@ -532,6 +532,34 @@ public interface FakeApi {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@ApiOperation(
|
||||
tags = { "fake" },
|
||||
value = "",
|
||||
nickname = "testWithResultExample",
|
||||
notes = "This endpoint defines an example value for its response schema.",
|
||||
response = Integer.class
|
||||
)
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "Success", response = Integer.class)
|
||||
})
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/fake/response-with-example",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
default ResponseEntity<Integer> testWithResultExample(
|
||||
|
||||
) {
|
||||
return getDelegate().testWithResultExample();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -318,6 +318,27 @@ public interface FakeApiDelegate {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
* @see FakeApi#testWithResultExample
|
||||
*/
|
||||
default ResponseEntity<Integer> testWithResultExample() {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "42";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -1088,6 +1088,23 @@ paths:
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/response-with-example:
|
||||
get:
|
||||
description: This endpoint defines an example value for its response schema.
|
||||
operationId: testWithResultExample
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
example: 42
|
||||
type: integer
|
||||
description: Success
|
||||
tags:
|
||||
- fake
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/test-query-parameters:
|
||||
put:
|
||||
description: To test the collection format in query parameters
|
||||
|
||||
@@ -578,6 +578,44 @@ public interface FakeApi {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@ApiOperation(
|
||||
tags = { "fake" },
|
||||
value = "",
|
||||
nickname = "testWithResultExample",
|
||||
notes = "This endpoint defines an example value for its response schema.",
|
||||
response = Integer.class
|
||||
)
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "Success", response = Integer.class)
|
||||
})
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/fake/response-with-example",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
default ResponseEntity<Integer> testWithResultExample(
|
||||
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "42";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -1088,6 +1088,23 @@ paths:
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/response-with-example:
|
||||
get:
|
||||
description: This endpoint defines an example value for its response schema.
|
||||
operationId: testWithResultExample
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
example: 42
|
||||
type: integer
|
||||
description: Success
|
||||
tags:
|
||||
- fake
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/test-query-parameters:
|
||||
put:
|
||||
description: To test the collection format in query parameters
|
||||
|
||||
@@ -45,7 +45,7 @@ public interface AnotherFakeApiDelegate {
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"client\" : \"client\" }";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,6 +552,34 @@ public interface FakeApi {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@ApiOperation(
|
||||
tags = { "fake" },
|
||||
value = "",
|
||||
nickname = "testWithResultExample",
|
||||
notes = "This endpoint defines an example value for its response schema.",
|
||||
response = Integer.class
|
||||
)
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "Success", response = Integer.class)
|
||||
})
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/fake/response-with-example",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
default Mono<ResponseEntity<Integer>> testWithResultExample(
|
||||
@ApiIgnore final ServerWebExchange exchange
|
||||
) {
|
||||
return getDelegate().testWithResultExample(exchange);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -88,7 +88,7 @@ public interface FakeApiDelegate {
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("*/*"))) {
|
||||
String exampleString = "{ \"my_string\" : \"my_string\", \"my_number\" : 0.8008281904610115, \"my_boolean\" : true }";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public interface FakeApiDelegate {
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"UPPER_CASE_PROPERTY_SNAKE\" : \"UPPER_CASE_PROPERTY_SNAKE\", \"lower-case-property-dashes\" : \"lower-case-property-dashes\", \"property name with spaces\" : \"property name with spaces\", \"normalPropertyName\" : \"normalPropertyName\" }";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ public interface FakeApiDelegate {
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"client\" : \"client\" }";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -362,6 +362,27 @@ public interface FakeApiDelegate {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
* @see FakeApi#testWithResultExample
|
||||
*/
|
||||
default Mono<ResponseEntity<Integer>> testWithResultExample(ServerWebExchange exchange) {
|
||||
Mono<Void> result = Mono.empty();
|
||||
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "42";
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result.then(Mono.empty());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
@@ -381,7 +402,7 @@ public interface FakeApiDelegate {
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public interface FakeClassnameTestApiDelegate {
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"client\" : \"client\" }";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,12 +84,12 @@ public interface PetApiDelegate {
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/xml"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -115,12 +115,12 @@ public interface PetApiDelegate {
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/xml"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -145,12 +145,12 @@ public interface PetApiDelegate {
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"default-name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/xml"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -216,7 +216,7 @@ public interface PetApiDelegate {
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,12 +79,12 @@ public interface StoreApiDelegate {
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Order> <id>123456789</id> <petId>123456789</petId> <quantity>123</quantity> <shipDate>2000-01-23T04:56:07.000Z</shipDate> <status>aeiou</status> <complete>true</complete> </Order>";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/xml"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -108,12 +108,12 @@ public interface StoreApiDelegate {
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Order> <id>123456789</id> <petId>123456789</petId> <quantity>123</quantity> <shipDate>2000-01-23T04:56:07.000Z</shipDate> <status>aeiou</status> <complete>true</complete> </Order>";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/xml"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,12 +113,12 @@ public interface UserApiDelegate {
|
||||
for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/json"), exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<User> <id>123456789</id> <username>aeiou</username> <firstName>aeiou</firstName> <lastName>aeiou</lastName> <email>aeiou</email> <password>aeiou</password> <phone>aeiou</phone> <userStatus>123</userStatus> </User>";
|
||||
result = ApiUtil.getExampleResponse(exchange, mediaType, exampleString);
|
||||
result = ApiUtil.getExampleResponse(exchange, MediaType.valueOf("application/xml"), exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1088,6 +1088,23 @@ paths:
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/response-with-example:
|
||||
get:
|
||||
description: This endpoint defines an example value for its response schema.
|
||||
operationId: testWithResultExample
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
example: 42
|
||||
type: integer
|
||||
description: Success
|
||||
tags:
|
||||
- fake
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/test-query-parameters:
|
||||
put:
|
||||
description: To test the collection format in query parameters
|
||||
|
||||
@@ -578,6 +578,44 @@ public interface FakeApi {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@ApiOperation(
|
||||
tags = { "fake" },
|
||||
value = "",
|
||||
nickname = "testWithResultExample",
|
||||
notes = "This endpoint defines an example value for its response schema.",
|
||||
response = Integer.class
|
||||
)
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "Success", response = Integer.class)
|
||||
})
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/fake/response-with-example",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
default ResponseEntity<Integer> testWithResultExample(
|
||||
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "42";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -1088,6 +1088,23 @@ paths:
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/response-with-example:
|
||||
get:
|
||||
description: This endpoint defines an example value for its response schema.
|
||||
operationId: testWithResultExample
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
example: 42
|
||||
type: integer
|
||||
description: Success
|
||||
tags:
|
||||
- fake
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/test-query-parameters:
|
||||
put:
|
||||
description: To test the collection format in query parameters
|
||||
|
||||
@@ -602,6 +602,45 @@ public interface FakeApi {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@ApiVirtual
|
||||
@Operation(
|
||||
operationId = "testWithResultExample",
|
||||
description = "This endpoint defines an example value for its response schema.",
|
||||
tags = { "fake" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "Success", content = {
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Integer.class))
|
||||
})
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/fake/response-with-example",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
default ResponseEntity<Integer> testWithResultExample(
|
||||
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "42";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -1088,6 +1088,23 @@ paths:
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/response-with-example:
|
||||
get:
|
||||
description: This endpoint defines an example value for its response schema.
|
||||
operationId: testWithResultExample
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
example: 42
|
||||
type: integer
|
||||
description: Success
|
||||
tags:
|
||||
- fake
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/test-query-parameters:
|
||||
put:
|
||||
description: To test the collection format in query parameters
|
||||
|
||||
@@ -578,6 +578,44 @@ public interface FakeApi {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /fake/response-with-example
|
||||
* This endpoint defines an example value for its response schema.
|
||||
*
|
||||
* @return Success (status code 200)
|
||||
*/
|
||||
@ApiOperation(
|
||||
tags = { "fake" },
|
||||
value = "",
|
||||
nickname = "testWithResultExample",
|
||||
notes = "This endpoint defines an example value for its response schema.",
|
||||
response = Integer.class
|
||||
)
|
||||
@ApiResponses({
|
||||
@ApiResponse(code = 200, message = "Success", response = Integer.class)
|
||||
})
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/fake/response-with-example",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
default ResponseEntity<Integer> testWithResultExample(
|
||||
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "42";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /fake/{petId}/uploadImageWithRequiredFile : uploads an image (required)
|
||||
*
|
||||
|
||||
@@ -1088,6 +1088,23 @@ paths:
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/response-with-example:
|
||||
get:
|
||||
description: This endpoint defines an example value for its response schema.
|
||||
operationId: testWithResultExample
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
example: 42
|
||||
type: integer
|
||||
description: Success
|
||||
tags:
|
||||
- fake
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: fake
|
||||
/fake/test-query-parameters:
|
||||
put:
|
||||
description: To test the collection format in query parameters
|
||||
|
||||
Reference in New Issue
Block a user