Add index-support, type hints and improve documentation #4
@ -46,9 +46,24 @@ public class MockFileParser {
|
|||||||
*/
|
*/
|
||||||
public void parseFile(Path file, String relativePath, List<MockEndpoint> endpoints, MockValidator validator) {
|
public void parseFile(Path file, String relativePath, List<MockEndpoint> endpoints, MockValidator validator) {
|
||||||
String basePath = "/" + relativePath;
|
String basePath = "/" + relativePath;
|
||||||
|
if (basePath.endsWith("/index")) {
|
||||||
|
basePath = basePath.substring(0, basePath.length() - "/index".length());
|
||||||
|
}
|
||||||
|
|
||||||
try (InputStream input = Files.newInputStream(file)) {
|
try (InputStream input = Files.newInputStream(file)) {
|
||||||
List<?> rawList = yaml.load(input);
|
Object root = yaml.load(input);
|
||||||
|
|
||||||
|
// Handle empty file
|
||||||
|
if (root == null) {
|
||||||
|
LOGGER.warn("⚠️ Skipping empty YAML file: {}", file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the root YAML object is a list
|
||||||
|
if (!(root instanceof List<?> rawList)) {
|
||||||
|
LOGGER.error("❌ Expected a YAML list in file: {} but got {}", file, root.getClass().getSimpleName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (Object obj : rawList) {
|
for (Object obj : rawList) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user