Skip to content

Commit b66a584

Browse files
committed
fix and exposed id$
1 parent 591301c commit b66a584

File tree

9 files changed

+147
-21
lines changed

9 files changed

+147
-21
lines changed

src/main/java/io/swagger/petstore/model/Category.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@Schema(
99
description = "Category",
10-
$id = "/components/schemas/category"
10+
$id = "/api/v31/components/schemas/category"
1111
)
1212
@XmlRootElement(name = "Category")
1313
public class Category {

src/main/java/io/swagger/petstore/model/Pet.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void setStatus(final String status) {
9191
this.status = status;
9292
}
9393

94-
@Schema(name = "petDetails", ref = "/components/schemas/petdetails")
94+
@Schema(name = "petDetails", ref = "/api/v31/components/schemas/petdetails")
9595
public PetDetails getPetDetails() {
9696
return petDetails;
9797
}
@@ -126,7 +126,7 @@ public void setAvailableInstances(final int availableInstances) {
126126
}
127127

128128
@XmlElement(name = "petDetailsId")
129-
@Schema(name = "petDetailsId", ref = "/components/schemas/petdetails#pet_details_id")
129+
@Schema(name = "petDetailsId", ref = "/api/v31/components/schemas/petdetails#pet_details_id")
130130
public long getPetDetailsId() {
131131
return petDetailsId;
132132
}

src/main/java/io/swagger/petstore/model/PetDetails.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@Schema(
1212
$schema = "https://json-schema.org/draft/2020-12/schema",
1313
$vocabulary = "https://spec.openapis.org/oas/3.1/schema-base",
14-
$id = "/components/schemas/petdetails",
14+
$id = "/api/v31/components/schemas/petdetails",
1515
type = "object"
1616
)
1717
public class PetDetails {
@@ -32,7 +32,7 @@ public void setId(final Long id) {
3232
this.id = id;
3333
}
3434

35-
@Schema(description = "PetDetails Category", ref = "/components/schemas/category")
35+
@Schema(description = "PetDetails Category", ref = "/api/v31/components/schemas/category")
3636
public Category getCategory() {
3737
return category;
3838
}
@@ -41,7 +41,7 @@ public void setCategory(final Category category) {
4141
this.category = category;
4242
}
4343

44-
@Schema(ref = "/components/schemas/tag")
44+
@Schema(ref = "/api/v31/components/schemas/tag")
4545
public Tag getTag() {
4646
return tag;
4747
}

src/main/java/io/swagger/petstore/model/Tag.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import javax.xml.bind.annotation.XmlRootElement;
77

88
@Schema(
9-
$id = "/components/schemas/tag"
9+
$id = "/api/v31/components/schemas/tag"
1010
)
1111
@XmlRootElement(name = "Tag")
1212
public class Tag {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package io.swagger.petstore.resource;
2+
3+
import io.swagger.petstore.data.PetData;
4+
import io.swagger.v3.oas.annotations.Hidden;
5+
import javax.ws.rs.GET;
6+
import javax.ws.rs.Path;
7+
import javax.ws.rs.Produces;
8+
import javax.ws.rs.core.MediaType;
9+
import javax.ws.rs.core.Response;
10+
11+
@Path("/components/schemas/category")
12+
@Produces({"application/json"})
13+
public class CategoryResource {
14+
static PetData petData = new PetData();
15+
16+
@GET
17+
@Hidden
18+
public Response category() {
19+
String json = "{\n" +
20+
" \"Category\" : {\n" +
21+
" \"$id\" : \"/api/v31/components/schemas/category\",\n" +
22+
" \"description\" : \"Category\",\n" +
23+
" \"properties\" : {\n" +
24+
" \"id\" : {\n" +
25+
" \"type\" : \"integer\",\n" +
26+
" \"format\" : \"int64\",\n" +
27+
" \"example\" : 1\n" +
28+
" },\n" +
29+
" \"name\" : {\n" +
30+
" \"type\" : \"string\",\n" +
31+
" \"example\" : \"Dogs\"\n" +
32+
" }\n" +
33+
" },\n" +
34+
" \"xml\" : {\n" +
35+
" \"name\" : \"Category\"\n" +
36+
" }\n" +
37+
" }\n" +
38+
"}";
39+
40+
return Response.ok(json, MediaType.APPLICATION_JSON).build();
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package io.swagger.petstore.resource;
2+
3+
import io.swagger.petstore.data.PetData;
4+
import io.swagger.v3.oas.annotations.Hidden;
5+
6+
import javax.ws.rs.GET;
7+
import javax.ws.rs.Path;
8+
import javax.ws.rs.Produces;
9+
import javax.ws.rs.core.MediaType;
10+
import javax.ws.rs.core.Response;
11+
12+
@Path("/components/schemas/petdetails")
13+
@Produces({"application/json"})
14+
public class PetDetailsResource {
15+
static PetData petData = new PetData();
16+
17+
@GET
18+
@Hidden
19+
public Response petDetails() {
20+
String json = "{\n" +
21+
" \"$id\": \"/api/v31/components/schemas/petdetails\",\n" +
22+
" \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n" +
23+
" \"$vocabulary\": \"https://spec.openapis.org/oas/3.1/schema-base\",\n" +
24+
" \"properties\": {\n" +
25+
" \"id\": {\n" +
26+
" \"type\": \"integer\",\n" +
27+
" \"format\": \"int64\",\n" +
28+
" \"$anchor\": \"pet_details_id\",\n" +
29+
" \"example\": 10\n" +
30+
" },\n" +
31+
" \"category\": {\n" +
32+
" \"$ref\": \"/api/v31/components/schemas/category\",\n" +
33+
" \"description\": \"PetDetails Category\"\n" +
34+
" },\n" +
35+
" \"tag\": {\n" +
36+
" \"$ref\": \"/api/v31/components/schemas/tag\"\n" +
37+
" }\n" +
38+
" },\n" +
39+
" \"xml\": {\n" +
40+
" \"name\": \"PetDetails\"\n" +
41+
" }\n" +
42+
"}";
43+
44+
return Response.ok(json, MediaType.APPLICATION_JSON).build();
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package io.swagger.petstore.resource;
2+
3+
import io.swagger.petstore.data.PetData;
4+
import io.swagger.v3.oas.annotations.Hidden;
5+
6+
import javax.ws.rs.GET;
7+
import javax.ws.rs.Path;
8+
import javax.ws.rs.Produces;
9+
import javax.ws.rs.core.MediaType;
10+
import javax.ws.rs.core.Response;
11+
12+
@Path("/components/schemas/tag")
13+
@Produces({"application/json"})
14+
public class TagResource {
15+
static PetData petData = new PetData();
16+
17+
@GET
18+
@Hidden
19+
public Response tag() {
20+
String json = "{\n" +
21+
" \"$id\": \"/api/v3/components/schemas/tag\",\n" +
22+
" \"properties\": {\n" +
23+
" \"id\": {\n" +
24+
" \"type\": \"integer\",\n" +
25+
" \"format\": \"int64\"\n" +
26+
" },\n" +
27+
" \"name\": {\n" +
28+
" \"type\": \"string\"\n" +
29+
" }\n" +
30+
" },\n" +
31+
" \"xml\": {\n" +
32+
" \"name\": \"Tag\"\n" +
33+
" }\n" +
34+
"}";
35+
36+
return Response.ok(json, MediaType.APPLICATION_JSON).build();
37+
}
38+
}

src/main/webapp/code-first/openapi.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@
214214
"components" : {
215215
"schemas" : {
216216
"Category" : {
217-
"$id" : "/components/schemas/category",
217+
"$id" : "/api/v31/components/schemas/category",
218218
"description" : "Category",
219219
"properties" : {
220220
"id" : {
@@ -285,10 +285,10 @@
285285
"petDetailsId" : {
286286
"type" : "integer",
287287
"format" : "int64",
288-
"$ref" : "/components/schemas/petdetails#pet_details_id"
288+
"$ref" : "/api/v31/components/schemas/petdetails#pet_details_id"
289289
},
290290
"petDetails" : {
291-
"$ref" : "/components/schemas/petdetails"
291+
"$ref" : "/api/v31/components/schemas/petdetails"
292292
}
293293
},
294294
"required" : [ "name", "photoUrls" ],
@@ -297,7 +297,7 @@
297297
}
298298
},
299299
"PetDetails" : {
300-
"$id" : "/components/schemas/petdetails",
300+
"$id" : "/api/v31/components/schemas/petdetails",
301301
"$schema" : "https://json-schema.org/draft/2020-12/schema",
302302
"$vocabulary" : "https://spec.openapis.org/oas/3.1/schema-base",
303303
"properties" : {
@@ -308,19 +308,19 @@
308308
"example" : 10
309309
},
310310
"category" : {
311-
"$ref" : "/components/schemas/category",
311+
"$ref" : "/api/v31/components/schemas/category",
312312
"description" : "PetDetails Category"
313313
},
314314
"tag" : {
315-
"$ref" : "/components/schemas/tag"
315+
"$ref" : "/api/v31/components/schemas/tag"
316316
}
317317
},
318318
"xml" : {
319319
"name" : "PetDetails"
320320
}
321321
},
322322
"Tag" : {
323-
"$id" : "/components/schemas/tag",
323+
"$id" : "/api/v31/components/schemas/tag",
324324
"properties" : {
325325
"id" : {
326326
"type" : "integer",

src/main/webapp/code-first/openapi.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ paths:
169169
components:
170170
schemas:
171171
Category:
172-
$id: /components/schemas/category
172+
$id: /api/v31/components/schemas/category
173173
description: Category
174174
properties:
175175
id:
@@ -226,16 +226,16 @@ components:
226226
petDetailsId:
227227
type: integer
228228
format: int64
229-
$ref: /components/schemas/petdetails#pet_details_id
229+
$ref: /api/v31/components/schemas/petdetails#pet_details_id
230230
petDetails:
231-
$ref: /components/schemas/petdetails
231+
$ref: /api/v31/components/schemas/petdetails
232232
required:
233233
- name
234234
- photoUrls
235235
xml:
236236
name: Pet
237237
PetDetails:
238-
$id: /components/schemas/petdetails
238+
$id: /api/v31/components/schemas/petdetails
239239
$schema: https://json-schema.org/draft/2020-12/schema
240240
$vocabulary: https://spec.openapis.org/oas/3.1/schema-base
241241
properties:
@@ -245,14 +245,14 @@ components:
245245
$anchor: pet_details_id
246246
example: 10
247247
category:
248-
$ref: /components/schemas/category
248+
$ref: /api/v31/components/schemas/category
249249
description: PetDetails Category
250250
tag:
251-
$ref: /components/schemas/tag
251+
$ref: /api/v31/components/schemas/tag
252252
xml:
253253
name: PetDetails
254254
Tag:
255-
$id: /components/schemas/tag
255+
$id: /api/v31/components/schemas/tag
256256
properties:
257257
id:
258258
type: integer

0 commit comments

Comments
 (0)