Known issues

This page lists known issues with the Typescript code that gets generated by the openapi-generator.

Creating GeoJSON area of interest/background layers

The request to create a GeoJSON Area of interest or background layer requires you to include both a

  • File (the GeoJSON file)

  • JSON body with additional information

in the request.

The code generated by the library seems unable to deal with that. Typically, this results in a TypeError: source.on is not a function error.

The workaround for that request is to bypass the generated code and make your own network call.

The following snippet shows how to achieve this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { CreatePublicGeoJSONMapDataRequest } from "./gen/model/createPublicGeoJSONMapDataRequest";
import { ReadStream } from "fs";
import FormData from "form-data";
import axios from "axios";
import { BackgroundLayersAndAreasOfInterestMapdataApi } from "./gen/api/backgroundLayersAndAreasOfInterestMapdataApi";
import { Readable } from "stream";
import { PublicMapDataDTO } from "./gen/model/publicMapDataDTO";


export async function createGeoJSONMapData(
  request: CreatePublicGeoJSONMapDataRequest,
  contentsStream: ReadStream | Readable,
  jwtToken: string
): Promise<PublicMapDataDTO> {
  const form = new FormData();
  form.append("json", JSON.stringify(request), { contentType: "application/json" });
  form.append("file", contentsStream, { filename: "data.geojson" });

  const headers = form.getHeaders();
  headers["Content-Type"] = "multipart/form-data";
  headers["Authorization"] = `Bearer ${jwtToken}`;

  const basePath = new BackgroundLayersAndAreasOfInterestMapdataApi().basePath;

  return (await axios.post(`${basePath}/public/api/mapdata/geojson`, form, { headers: headers }))
    .data;
}

It requires to install the axios and form-data library:

# Install axis
npm install --save --save-exact axios@0.26.1
# Install form-data
npm install --save --save-exact form-data@2.5.1