Skip to content

Commit bc7acb8

Browse files
author
bnasslahsen
committed
( self ref) for HAL hypermedia types. Fixes #609
1 parent 7ce0bf1 commit bc7acb8

File tree

4 files changed

+113
-35
lines changed

4 files changed

+113
-35
lines changed

springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/SpringDocDataRestConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ OpenApiCustomiser linksSchemaCustomiser(HalProvider halProvider) {
107107
Json.mapper().addMixIn(RepresentationModel.class, RepresentationModelLinksOASMixin.class);
108108

109109
ResolvedSchema resolvedLinkSchema = ModelConverters.getInstance()
110-
.resolveAsResolvedSchema(new AnnotatedType(Link.class).resolveAsRef(true));
110+
.resolveAsResolvedSchema(new AnnotatedType(Link.class));
111111

112112
return openApi -> openApi
113113
.schema("Link", resolvedLinkSchema.schema)

springdoc-openapi-data-rest/src/test/resources/results/app4.json

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -125,25 +125,6 @@
125125
},
126126
"components": {
127127
"schemas": {
128-
"CollectionModelEntityModelEmployee": {
129-
"type": "object",
130-
"properties": {
131-
"_embedded": {
132-
"type": "object",
133-
"properties": {
134-
"employees": {
135-
"type": "array",
136-
"items": {
137-
"$ref": "#/components/schemas/EntityModelEmployee"
138-
}
139-
}
140-
}
141-
},
142-
"_links": {
143-
"$ref": "#/components/schemas/Links"
144-
}
145-
}
146-
},
147128
"Employee": {
148129
"type": "object",
149130
"properties": {
@@ -189,9 +170,54 @@
189170
"$ref": "#/components/schemas/Link"
190171
}
191172
},
173+
"CollectionModelEntityModelEmployee": {
174+
"type": "object",
175+
"properties": {
176+
"_embedded": {
177+
"type": "object",
178+
"properties": {
179+
"employees": {
180+
"type": "array",
181+
"items": {
182+
"$ref": "#/components/schemas/EntityModelEmployee"
183+
}
184+
}
185+
}
186+
},
187+
"_links": {
188+
"$ref": "#/components/schemas/Links"
189+
}
190+
}
191+
},
192192
"Link": {
193-
"$ref": "#/components/schemas/Link"
193+
"type": "object",
194+
"properties": {
195+
"href": {
196+
"type": "string"
197+
},
198+
"hreflang": {
199+
"type": "string"
200+
},
201+
"title": {
202+
"type": "string"
203+
},
204+
"type": {
205+
"type": "string"
206+
},
207+
"deprecation": {
208+
"type": "string"
209+
},
210+
"profile": {
211+
"type": "string"
212+
},
213+
"name": {
214+
"type": "string"
215+
},
216+
"templated": {
217+
"type": "boolean"
218+
}
219+
}
194220
}
195221
}
196222
}
197-
}
223+
}

springdoc-openapi-data-rest/src/test/resources/results/app6.json

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@
4545
},
4646
"components": {
4747
"schemas": {
48+
"ExceptionMessage": {
49+
"type": "object",
50+
"properties": {
51+
"cause": {
52+
"$ref": "#/components/schemas/ExceptionMessage"
53+
},
54+
"message": {
55+
"type": "string"
56+
}
57+
}
58+
},
4859
"RepositoryConstraintViolationExceptionMessage": {
4960
"type": "object",
5061
"properties": {
@@ -73,17 +84,6 @@
7384
}
7485
}
7586
},
76-
"ExceptionMessage": {
77-
"type": "object",
78-
"properties": {
79-
"cause": {
80-
"$ref": "#/components/schemas/ExceptionMessage"
81-
},
82-
"message": {
83-
"type": "string"
84-
}
85-
}
86-
},
8787
"Employee": {
8888
"type": "object",
8989
"properties": {
@@ -130,7 +130,33 @@
130130
}
131131
},
132132
"Link": {
133-
"$ref": "#/components/schemas/Link"
133+
"type": "object",
134+
"properties": {
135+
"href": {
136+
"type": "string"
137+
},
138+
"hreflang": {
139+
"type": "string"
140+
},
141+
"title": {
142+
"type": "string"
143+
},
144+
"type": {
145+
"type": "string"
146+
},
147+
"deprecation": {
148+
"type": "string"
149+
},
150+
"profile": {
151+
"type": "string"
152+
},
153+
"name": {
154+
"type": "string"
155+
},
156+
"templated": {
157+
"type": "boolean"
158+
}
159+
}
134160
}
135161
}
136162
}

springdoc-openapi-data-rest/src/test/resources/results/app8.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,33 @@
9898
}
9999
},
100100
"Link": {
101-
"$ref": "#/components/schemas/Link"
101+
"type": "object",
102+
"properties": {
103+
"href": {
104+
"type": "string"
105+
},
106+
"hreflang": {
107+
"type": "string"
108+
},
109+
"title": {
110+
"type": "string"
111+
},
112+
"type": {
113+
"type": "string"
114+
},
115+
"deprecation": {
116+
"type": "string"
117+
},
118+
"profile": {
119+
"type": "string"
120+
},
121+
"name": {
122+
"type": "string"
123+
},
124+
"templated": {
125+
"type": "boolean"
126+
}
127+
}
102128
}
103129
}
104130
}

0 commit comments

Comments
 (0)