Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.

Commit 97145e7

Browse files
committed
fix JSON parsing, add meta info
1 parent e59f2d9 commit 97145e7

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

java/java-cxf-spring-boot-minimal/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,9 @@
7474
<artifactId>cxf-rt-rs-service-description-openapi-v3</artifactId>
7575
<version>${cxf.version}</version>
7676
</dependency>
77+
<dependency>
78+
<groupId>com.fasterxml.jackson.jaxrs</groupId>
79+
<artifactId>jackson-jaxrs-json-provider</artifactId>
80+
</dependency>
7781
</dependencies>
7882
</project>

java/java-cxf-spring-boot-minimal/src/main/java/io/swagger/sample/MyApplication.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55

6-
import javax.ws.rs.ApplicationPath;
7-
import javax.ws.rs.core.Application;
8-
96
@SpringBootApplication
107
public class MyApplication {
118

java/java-cxf-spring-boot-minimal/src/main/java/io/swagger/sample/resource/PetResource.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616

1717
package io.swagger.sample.resource;
1818

19+
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
1920
import io.swagger.v3.oas.annotations.Operation;
2021
import io.swagger.v3.oas.annotations.Parameter;
22+
import io.swagger.v3.oas.annotations.info.Info;
2123
import io.swagger.v3.oas.annotations.media.Content;
2224
import io.swagger.v3.oas.annotations.media.Schema;
2325
import io.swagger.v3.oas.annotations.responses.ApiResponse;
2426
import io.swagger.sample.data.PetData;
2527
import io.swagger.sample.model.Pet;
28+
import io.swagger.v3.oas.annotations.servers.Server;
2629
import org.springframework.stereotype.Service;
2730

2831
import javax.ws.rs.BeanParam;
@@ -34,12 +37,15 @@
3437
import javax.ws.rs.Produces;
3538
import javax.ws.rs.Consumes;
3639
import javax.ws.rs.QueryParam;
40+
import javax.ws.rs.core.MediaType;
3741
import javax.ws.rs.core.Response;
3842
import java.util.List;
3943

4044
@Service
45+
@OpenAPIDefinition(
46+
info = @Info(title = "Petstore", version = "2.0.0", description = "This is a sample Petstore server."))
4147
@Path("/pet")
42-
@Produces({"application/json", "application/xml"})
48+
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
4349
public class PetResource {
4450
static PetData petData = new PetData();
4551

@@ -75,7 +81,7 @@ public Pet getPetById(
7581
}
7682

7783
@POST
78-
@Consumes("application/json")
84+
@Consumes(MediaType.APPLICATION_JSON)
7985
@Operation(summary = "Add a new pet to the store",
8086
tags = {"pets"},
8187
responses = {
@@ -88,6 +94,7 @@ public Response addPet(
8894
}
8995

9096
@PUT
97+
@Consumes(MediaType.APPLICATION_JSON)
9198
@Operation(summary = "Update an existing pet",
9299
tags = {"pets"},
93100
responses = {
@@ -107,7 +114,7 @@ public Response updatePet(
107114
description = "Multiple status values can be provided with comma seperated strings",
108115
responses = {
109116
@ApiResponse(
110-
content = @Content(mediaType = "application/json",
117+
content = @Content(mediaType = MediaType.APPLICATION_JSON,
111118
schema = @Schema(implementation = Pet.class))),
112119
@ApiResponse(
113120
responseCode = "400", description = "Invalid status value"
@@ -135,7 +142,7 @@ public List<Pet> findPetsByStatus(
135142
description = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
136143
responses = {
137144
@ApiResponse(description = "Pets matching criteria",
138-
content = @Content(mediaType = "application/json",
145+
content = @Content(mediaType = MediaType.APPLICATION_JSON,
139146
schema = @Schema(implementation = Pet.class))
140147
),
141148
@ApiResponse(description = "Invalid tag value", responseCode = "400")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cxf:
22
jaxrs:
33
component-scan: true
4-
classes-scan-packages: org.apache.cxf.jaxrs.openapi,org.apache.cxf.metrics
4+
classes-scan-packages: org.apache.cxf.jaxrs.openapi,org.apache.cxf.metrics,com.fasterxml.jackson.jaxrs.json

0 commit comments

Comments
 (0)