Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$ref fix #24

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
- node/install:
node-version: << pipeline.parameters.node-version >>
- setup_remote_docker:
version: 19.03.13
version: default
docker_layer_caching: true
# build and push Docker image
- run:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.2.10 (November 21, 2024)
* Fixed issue when you have `$ref` in generated metadata

# 1.2.9 (April 8, 2022)
* Added possibility to handle WSDL files where the "message" doesn't contain an element
* Updated the Sailor version to 3.3.9
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "SOAP V2",
"service": "request-reply",
"version": "1.2.9",
"version": "1.2.10",
"description": "Generic SOAP / WebServices integration Component",
"docsUrl": "https://docs.elastic.io/components/soap/",
"credentials": {
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/io/elastic/soap/providers/BodyMetaProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.util.Map;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.JsonValue;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;

Expand Down Expand Up @@ -82,6 +84,21 @@ private JsonObject generateSchema(final Message message, final String operationN
throw new ComponentException("Could not parse xml, SAXE exception caught", e);
}
}
public static JsonObject removeRefKeys(JsonObject jsonObject) {
JsonObjectBuilder builder = Json.createObjectBuilder();

for (String key : jsonObject.keySet()) {
if (!"$ref".equals(key)) {
JsonValue value = jsonObject.get(key);
if (value instanceof JsonObject) {
value = removeRefKeys((JsonObject) value);
}
builder.add(key, value);
}
}

return builder.build();
}

@Override
public JsonObject getMetaModel(final JsonObject configuration) {
Expand All @@ -105,8 +122,9 @@ public JsonObject getMetaModel(final JsonObject configuration) {
.add("in", in)
.add("out", out)
.build();
JsonObject cleanedResult = removeRefKeys(result);
LOGGER.info("Successfully generated component metadata");
return result;
return cleanedResult;
} catch (ComponentException e) {
throw e;
} catch (Exception e) {
Expand Down