Creating TypeMapping from inputStream not working

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

Describe the issue:

Using the Java client I want my app to be able create and configure the index. I want to load an explicit mapping from file. The simple problem is, I don’t seem to be able to create the TypeMapping object properly - it always looks empty and my index is created with dynamic mapping.

I’ve tried creating the transport with and without a provided mapper, I’ve even tried adding additional modules, which I think are unnecessary.

    ObjectMapper mapper = JsonMapper.builder()
      .addModule(new Jdk8Module())
      .addModule(new JavaTimeModule())
      .build();

    // Create Transport
    transport = ApacheHttpClient5TransportBuilder.builder(host)
      .setHttpClientConfigCallback(httpClientBuilder -> {
        final PoolingAsyncClientConnectionManager connectionManager = PoolingAsyncClientConnectionManagerBuilder
            .create()
            .build();

        if (credentialsProvider != null) {
          httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
        }

        return httpClientBuilder.setConnectionManager(connectionManager);
      })
      .setMapper(new JacksonJsonpMapper(mapper))
      .build();

    client = new OpenSearchClient(transport);

I then try to create the index with a TypeMapping, parsing my mapping.json from a valid inputStream:

      JsonpMapper mapper = client._transport().jsonpMapper();
      JsonProvider provider = mapper.jsonProvider();
      JsonParser parser = provider.createParser(getMapping());
      TypeMapping mapping = new TypeMapping.Builder().withJson(parser, mapper).build();

     
      CreateIndexRequest createIndexRequest = new CreateIndexRequest.Builder().index(site.getIdentifier())
          .mappings(mapping).build();
      CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest);

Examing the mapping in the debugger shows it has no properties. I tested with a small example mappings.json from the docs with no luck. I get no errors; adding a deliberate error into mapping.json made no difference

Creating the index using curl -X PUT /my-index -d @mapping.json works

Configuration

  "version" : {
    "distribution" : "opensearch",
    "number" : "2.18.0",
    "build_type" : "tar",
    "build_hash" : "99a9a81da366173b0c2b963b26ea92e15ef34547",
    "build_date" : "2024-10-31T19:08:39.157471098Z",
    "build_snapshot" : false,
    "lucene_version" : "9.12.0",
    "minimum_wire_compatibility_version" : "7.10.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },

java 11, OSGI application

opensearch-java 2.26.0 - embedded in osgi bundle

parson 1.1.7 - embedded in osgi bundle

jackson 2.17.3