Replies: 1 comment
|
You can do this with the Node API. I tested it by replacing the generated component definition instead of trying to handle every import openapiTS from "openapi-typescript";
import ts from "typescript";
const geoJsonTypes = new Map([
["#/components/schemas/Point", "Point"],
["#/components/schemas/Polygon", "Polygon"],
["#/components/schemas/MultiPolygon", "MultiPolygon"],
]);
const ast = await openapiTS(schema, {
inject:
'import type { Point, Polygon, MultiPolygon } from "geojson";',
transform(_schemaObject, metadata) {
const typeName = geoJsonTypes.get(metadata.path);
if (typeName) {
return ts.factory.createTypeReferenceNode(typeName);
}
},
});This produces |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I would like to use the native types for GeoJSON objects from the
geojsontypes package over the (broken) ones that are generated by springdoc. Is it possible to provide a mapping from a$refto a type import?All reactions