Skip to content

Commit 3ca798f

Browse files
authored
Support packages with no schemas (#577)
1 parent b3ea19f commit 3ca798f

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

onyxia-api/src/main/java/fr/insee/onyxia/api/controller/api/mylab/MyLabController.java

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ public JsonNode getSchemas(
174174
catalogService
175175
.getChartByVersion(catalogId, chartName, version)
176176
.orElseThrow(NotFoundException::new);
177-
177+
if (chart.getConfig() == null) {
178+
return null;
179+
}
178180
return jsonSchemaResolutionService.resolveReferences(chart.getConfig(), user.getRoles());
179181
}
180182

@@ -531,23 +533,26 @@ private Collection<Object> publishApps(
531533
Map<String, Object> fusion = new HashMap<>();
532534
fusion.putAll((Map<String, Object>) requestDTO.getOptions());
533535

534-
JSONObject jsonSchema =
535-
new JSONObject(
536-
new JSONTokener(
537-
jsonSchemaResolutionService
538-
.resolveReferences(pkg.getConfig(), user.getRoles())
539-
.toString()));
540-
541-
SchemaLoader loader =
542-
SchemaLoader.builder()
543-
.schemaJson(jsonSchema)
544-
.draftV6Support() // or draftV7Support()
545-
.build();
546-
org.everit.json.schema.Schema schema = loader.load().build();
547-
// Convert the options map to a JSONObject
548-
JSONObject jsonObject = new JSONObject(fusion);
549-
// Validate the options object against the schema
550-
schema.validate(jsonObject);
536+
// If getConfig is null that means that no schema is provided : skip validation
537+
if (pkg.getConfig() != null) {
538+
JSONObject jsonSchema =
539+
new JSONObject(
540+
new JSONTokener(
541+
jsonSchemaResolutionService
542+
.resolveReferences(pkg.getConfig(), user.getRoles())
543+
.toString()));
544+
545+
SchemaLoader loader =
546+
SchemaLoader.builder()
547+
.schemaJson(jsonSchema)
548+
.draftV6Support() // or draftV7Support()
549+
.build();
550+
org.everit.json.schema.Schema schema = loader.load().build();
551+
// Convert the options map to a JSONObject
552+
JSONObject jsonObject = new JSONObject(fusion);
553+
// Validate the options object against the schema
554+
schema.validate(jsonObject);
555+
}
551556

552557
boolean skipTlsVerify = catalog.getSkipTlsVerify();
553558
String caFile = catalog.getCaFile();

0 commit comments

Comments
 (0)