Skip to content

Commit b87edf8

Browse files
committed
Fixed missing @iot.selfLink / @id in OpenAPI schemas
1 parent 5ce23fb commit b87edf8

6 files changed

Lines changed: 42 additions & 15 deletions

File tree

FROST-Server.Core/src/main/java/de/fraunhofer/iosb/ilt/frostserver/service/PluginManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public class PluginManager implements ConfigDefaults {
5252
public static final String VALUE_PROVIDED_PLUGINS = "de.fraunhofer.iosb.ilt.frostserver.formatter.PluginResultFormatInternal"
5353
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.coremodel.PluginCoreService"
5454
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.coremodel.PluginCoreModel"
55+
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.coremodelv2.PluginCoreServiceV2"
56+
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.coremodelv2.PluginCoreModelV2"
5557
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.actuation.PluginActuation"
5658
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.multidatastream.PluginMultiDatastream"
5759
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.batchprocessing.PluginBatchProcessing"
@@ -60,14 +62,12 @@ public class PluginManager implements ConfigDefaults {
6062
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.format.geojson.PluginResultFormatGeoJson"
6163
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.odata.PluginOData"
6264
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.openapi.PluginOpenApi"
63-
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.modelloader.PluginModelLoader"
64-
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.coremodelv2.PluginCoreModelV2"
65-
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.coremodelv2.PluginCoreServiceV2"
6665
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.modelom.PluginModelOM"
6766
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.modelsampling.PluginModelSampling"
6867
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.modelrelations.PluginModelRelations"
6968
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.projects.PluginProjects"
70-
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.opencitysense.PluginOpenCitySense";
69+
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.opencitysense.PluginOpenCitySense"
70+
+ ",de.fraunhofer.iosb.ilt.frostserver.plugin.modelloader.PluginModelLoader";
7171

7272
/**
7373
* The plugins provided with FROST by default. When editing these, also

FROST-Server.Util/src/main/java/de/fraunhofer/iosb/ilt/frostserver/util/SimpleJsonMapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import tools.jackson.core.type.TypeReference;
2424
import tools.jackson.databind.DeserializationFeature;
2525
import tools.jackson.databind.JsonNode;
26+
import tools.jackson.databind.MapperFeature;
2627
import tools.jackson.databind.ObjectMapper;
2728
import tools.jackson.databind.cfg.EnumFeature;
2829
import tools.jackson.databind.json.JsonMapper;
@@ -55,6 +56,7 @@ public static ObjectMapper getSimpleObjectMapper() {
5556
.disable(EnumFeature.READ_ENUMS_USING_TO_STRING)
5657
.disable(EnumFeature.WRITE_ENUMS_USING_TO_STRING)
5758
.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)
59+
.disable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY)
5860
.addModule(new JSONPModule())
5961
.build();
6062
}

Plugins/OpenApi/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
<artifactId>FROST-Server.Plugin.CoreModel</artifactId>
3535
<version>${project.version}</version>
3636
</dependency>
37+
<dependency>
38+
<groupId>${project.groupId}</groupId>
39+
<artifactId>FROST-Server.Plugin.CoreModelV2</artifactId>
40+
<version>${project.version}</version>
41+
</dependency>
3742
<dependency>
3843
<groupId>${project.groupId}</groupId>
3944
<artifactId>FROST-Server.Plugin.OData</artifactId>

Plugins/OpenApi/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/openapi/PluginOpenApi.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import de.fraunhofer.iosb.ilt.frostserver.path.Version;
2424
import de.fraunhofer.iosb.ilt.frostserver.plugin.coremodel.PluginCoreService;
25+
import de.fraunhofer.iosb.ilt.frostserver.plugin.coremodelv2.PluginCoreServiceV2;
2526
import de.fraunhofer.iosb.ilt.frostserver.plugin.odata.PluginOData;
2627
import de.fraunhofer.iosb.ilt.frostserver.service.InitResult;
2728
import de.fraunhofer.iosb.ilt.frostserver.service.PluginRootDocument;
@@ -85,6 +86,7 @@ public Collection<Version> getVersions() {
8586
return Arrays.asList(
8687
PluginCoreService.V_1_0,
8788
PluginCoreService.V_1_1,
89+
PluginCoreServiceV2.VERSION_STA_2_0,
8890
PluginOData.VERSION_ODATA_40,
8991
PluginOData.VERSION_ODATA_401);
9092
}

Plugins/OpenApi/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/openapi/spec/OASchema.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,12 @@ private void addSubtypeComplex(Version version, TypeComplex typeComplex) {
204204
}
205205
}
206206

207-
public void addProperty(String name, OASchema property) {
207+
public OASchema addProperty(String name, OASchema property) {
208208
if (properties == null) {
209209
properties = new TreeMap<>();
210210
}
211211
properties.put(name, property);
212+
return this;
212213
}
213214

214215
/**
@@ -220,9 +221,11 @@ public String getRef() {
220221

221222
/**
222223
* @param ref the ref to set
224+
* @return this
223225
*/
224-
public void setRef(String ref) {
226+
public OASchema setRef(String ref) {
225227
this.ref = ref;
228+
return this;
226229
}
227230

228231
/**
@@ -234,9 +237,11 @@ public Type getType() {
234237

235238
/**
236239
* @param type the type to set
240+
* @return this
237241
*/
238-
public void setType(Type type) {
242+
public OASchema setType(Type type) {
239243
this.type = type;
244+
return this;
240245
}
241246

242247
/**
@@ -248,9 +253,11 @@ public Format getFormat() {
248253

249254
/**
250255
* @param format the format to set
256+
* @return this
251257
*/
252-
public void setFormat(Format format) {
258+
public OASchema setFormat(Format format) {
253259
this.format = format;
260+
return this;
254261
}
255262

256263
/**
@@ -262,9 +269,11 @@ public String getDescription() {
262269

263270
/**
264271
* @param description the description to set
272+
* @return this
265273
*/
266-
public void setDescription(String description) {
274+
public OASchema setDescription(String description) {
267275
this.description = description;
276+
return this;
268277
}
269278

270279
/**
@@ -276,9 +285,11 @@ public String getDeflt() {
276285

277286
/**
278287
* @param deflt the deflt to set
288+
* @return this
279289
*/
280-
public void setDeflt(String deflt) {
290+
public OASchema setDeflt(String deflt) {
281291
this.deflt = deflt;
292+
return this;
282293
}
283294

284295
/**
@@ -290,9 +301,11 @@ public OASchema getItems() {
290301

291302
/**
292303
* @param items the items to set
304+
* @return this
293305
*/
294-
public void setItems(OASchema items) {
306+
public OASchema setItems(OASchema items) {
295307
this.items = items;
308+
return this;
296309
}
297310

298311
/**
@@ -311,17 +324,20 @@ public Boolean getAdditionalProperties() {
311324

312325
/**
313326
* @param additionalProperties the additionalProperties to set
327+
* @return this
314328
*/
315-
public void setAdditionalProperties(Boolean additionalProperties) {
329+
public OASchema setAdditionalProperties(Boolean additionalProperties) {
316330
this.additionalProperties = additionalProperties;
331+
return this;
317332
}
318333

319334
public Boolean isReadOnly() {
320335
return readOnly;
321336
}
322337

323-
public void setReadOnly(boolean readOnly) {
338+
public OASchema setReadOnly(boolean readOnly) {
324339
this.readOnly = readOnly;
340+
return this;
325341
}
326342

327343
}

Plugins/OpenApi/src/main/java/de/fraunhofer/iosb/ilt/frostserver/plugin/openapi/spec/OpenApiGenerator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static OADoc generateOpenApiDocument(GeneratorContext context) {
6363
document.setInfo(new OADocInfo(
6464
"SensorThings " + context.getVersion().urlPart,
6565
"1.0.0",
66-
"Version " + context.getVersion().urlPart + " of the OGC SensorThings API, including Part 2 - Tasking."));
66+
"Version " + context.getVersion().urlPart + " of the OGC SensorThings API."));
6767
addComponents(context, document);
6868

6969
document.addServer(new OAServer(context.getServiceRootUrl(), "FROST-Server"));
@@ -137,7 +137,7 @@ private static void addComponents(GeneratorContext context, OADoc document) {
137137

138138
OASchema selfLink = new OASchema(OASchema.Type.STRING, null);
139139
selfLink.setReadOnly(true);
140-
selfLink.setDescription("The direct link to the entity");
140+
selfLink.setDescription("A globally unique identifier for an Entity.");
141141
document.getComponents().addSchema("selfLink", selfLink);
142142

143143
OASchema navLink = new OASchema(OASchema.Type.STRING, null);
@@ -435,6 +435,8 @@ private static void createEntitySchema(GeneratorContext context, EntityType enti
435435
final OASchema schema = new OASchema(OASchema.Type.OBJECT, null);
436436
components.addSchema(schemaName, schema);
437437

438+
schema.addProperty(version.selfLinkName, new OASchema("#/components/schemas/selfLink"));
439+
438440
for (Property property : entityType.getPropertySet()) {
439441
String propertyName = property.getJsonName();
440442
if (property instanceof EntityPropertyMain<?> epm) {

0 commit comments

Comments
 (0)