Skip to content

Commit dde1fdc

Browse files
committed
Make OpenApiRouteBuilder spec path cross-platform
The auto-built OpenAPI route embeds specFile.getAbsolutePath() into an EL `${read('...')}` string literal for the validator and mock-handler config. On Windows the absolute path uses the '\' separator, which the EL parser treats as an (invalid) escape sequence, so the generated route fails to parse and never loads. Normalise the platform separator to '/', which read()/File accept on every OS (no-op on Linux/macOS).
1 parent d326bcd commit dde1fdc

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

openig-core/src/main/java/org/forgerock/openig/handler/router/OpenApiRouteBuilder.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,15 @@ public JsonValue buildRouteJson(final OpenAPI spec, final File specFile,
108108
routeName, specFile.getName(), condition, baseUri != null ? baseUri : "<none>",
109109
failOnResponseViolation, mockMode);
110110

111+
// Normalise the platform path separator to '/': this path is embedded in an EL
112+
// read('...') string literal, where a Windows backslash (D:\...) is parsed as an
113+
// (invalid) escape sequence. Forward slashes are accepted by read()/File on every OS.
114+
final String absolutePath = specFile.getAbsolutePath();
115+
final String specPath = absolutePath == null ? null : absolutePath.replace(File.separatorChar, '/');
116+
111117
// ----- heap: OpenApiValidationFilter entry -----
112118
final Map<String, Object> validatorConfig = new LinkedHashMap<>();
113-
validatorConfig.put("spec", "${read('" + specFile.getAbsolutePath() + "')}");
119+
validatorConfig.put("spec", "${read('" + specPath + "')}");
114120
validatorConfig.put("failOnResponseViolation", failOnResponseViolation);
115121

116122
final Map<String, Object> validatorHeapObject = new LinkedHashMap<>();
@@ -125,7 +131,7 @@ public JsonValue buildRouteJson(final OpenAPI spec, final File specFile,
125131
if (mockMode) {
126132
// ----- heap: OpenApiMockResponseHandler entry -----
127133
final Map<String, Object> mockConfig = new LinkedHashMap<>();
128-
mockConfig.put("spec", "${read('" + specFile.getAbsolutePath() + "')}");
134+
mockConfig.put("spec", "${read('" + specPath + "')}");
129135

130136
final Map<String, Object> mockHeapObject = new LinkedHashMap<>();
131137
mockHeapObject.put("name", MOCK_HANDLER_HEAP_NAME);

0 commit comments

Comments
 (0)