Skip to content

Commit

Permalink
[2.x]: Fix params of @ExampleObject annotations in examples (#6785) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Captain1653 authored May 9, 2023
1 parent 3d08ecd commit d80d862
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
10 changes: 7 additions & 3 deletions examples/cors/src/main/resources/META-INF/openapi.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019, 2021 Oracle and/or its affiliates.
# Copyright (c) 2019, 2023 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,11 +45,11 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/GreetingMessage'
$ref: '#/components/schemas/GreetingUpdateMessage'
examples:
greeting:
summary: Example greeting message to update
value: New greeting message
value: {"greeting": "New greeting message"}
responses:
"200":
description: OK
Expand Down Expand Up @@ -77,3 +77,7 @@ components:
properties:
message:
type: string
GreetingUpdateMessage:
properties:
greeting:
type: string
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -129,11 +129,11 @@ public JsonObject getMessage(@PathParam("name") String name) {
description = "Conveys the new greeting prefix to use in building greetings",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = GreetingMessage.class),
schema = @Schema(implementation = GreetingUpdateMessage.class),
examples = @ExampleObject(
name = "greeting",
summary = "Example greeting message to update",
value = "New greeting message")))
value = "{\"greeting\": \"New greeting message\"}")))
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateGreeting(JsonObject jsonObject) {
Expand Down Expand Up @@ -184,4 +184,31 @@ public void setMessage(String message) {
this.message = message;
}
}

/**
* POJO defining the greeting to use in future messages.
*/
public static class GreetingUpdateMessage {

private String greeting;

/**
* Gets the greeting value.
*
* @return greeting value
*/
public String getGreeting() {
return greeting;
}

/**
* Sets the greeting value.
*
* @param greeting greeting value to set
*/
public void setGreeting(String greeting) {
this.greeting = greeting;
}
}

}
10 changes: 7 additions & 3 deletions examples/openapi/src/main/resources/META-INF/openapi.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019, 2021 Oracle and/or its affiliates.
# Copyright (c) 2019, 2023 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,11 +45,11 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/GreetingMessage'
$ref: '#/components/schemas/GreetingUpdateMessage'
examples:
greeting:
summary: Example greeting message to update
value: New greeting message
value: {"greeting": "New greeting message"}
responses:
"200":
description: OK
Expand Down Expand Up @@ -77,3 +77,7 @@ components:
properties:
message:
type: string
GreetingUpdateMessage:
properties:
greeting:
type: string

0 comments on commit d80d862

Please sign in to comment.