Open marcmesh opened 1 year ago
Hi
At present JsonSchema2Pojo delegates reading/parsing of JSON schema to FasterXML/Jackson: https://github.com/joelittlejohn/jsonschema2pojo/blob/80d827db93e4cc3848c4f297ebbfe4b3fd936272/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/ContentResolver.java#L76 which in turn most probably is using standard java URL::openStream/HttpURLConnection that does not support redirects between different protocols: https://github.com/openjdk/jdk/blob/c67bbcea92919fea9b6f7bbcde8ba4488289d174/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java#L991-L996
Please see also:
Hi @marcmesh , have you managed to make it work? I'm running into the same problem with exactly same JSON spec... The only workaround i could imagine so far would be to download all the JSON specs using bash
+curl
and then use some sed
replace magic..
You could create a custom RuleFactory
that would create SchemaStore
with customized ContentResolver
smht. like:
public class CustomRuleFactory extends RuleFactory {
@Override
public void setSchemaStore(SchemaStore schemaStore) {
super.setSchemaStore(new SchemaStore(
new ContentResolver() {
@Override
public JsonNode resolve(URI uri) {
return super.resolve(URI.create(uri.toString().replace("http://", "https://")));
}
},
getLogger()));
}
}
And configure CLI/plugin to use custom rulefactory
I ended up just cloning the spec from https://github.com/asyncapi/spec-json-schemas, then replaced the http
references with local ones.
Does this native HTTP Java client support HSTS. If enabled in asyncapi.com website, and supported by this client, the issue could be fixed.
I'm afraid it does not (don't know if HttpURLConnection could qualify as a "client").
Why not create an issue on asyncapi
asking to replace http
with https
?
Already done (kinda) so.
See https://asyncapi.slack.com/archives/C0230UAM6R3/p1697557159905629.
Should stay http
instead of https
due to reasons explained in linked articles (btw. OpenAPI is using http
as well).
I'm trying to generate Pojos for this schema: https://raw.githubusercontent.com/asyncapi/spec-json-schemas/master/schemas/2.6.0.json All of the references sub-schemas are referenced via http:// but then HTTP-redirecting to https:// For example:
But Jsonschema2Pojo is not following this Redirect: