You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I generate POJOs using openapitools generator in version 7.4.0 then for GeojsonGeometry object there is no subtypes defined and 'coordinates' property is an empty GeojsonGeometryCoordinates class without any properties inside.
It causes issue when I call e.g. GET operator/stations endpoint:
Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'Point' as a subtype of org.tompapiclient.tompapi.model.GeojsonGeometry: known type ids = [geojsonGeometry] (for POJO property 'stationArea')
It happens because of wrongly defined GeojsonGeometry object, with discriminator on wrong level, without mapping between 'type' enum and subtypes.
Expected Behavior
There should be GeojsonGeometry object generated with proper subtypes (GeojsonPoint, GeojsonLine, GeojsonPolygon, GeojsonMultiPolygon) and every subtype class needs to have 'coordinates' property, since it's specific for the subtype.
Current Behavior
GeojsonGeometry object is generated without sybtypes, with two properties: 'type' and 'coordinates', where 'coordinates' is another empty object (GeojsonGeometryCoordinates).
Possible Solution
The following solution works as expected and doesn't break geojson standard:
geojsonGeometry:
type: object
discriminator:
propertyName: type
mapping:
Point: "#/components/schemas/geojsonPoint"
LineString: "#/components/schemas/geojsonLine"
Polygon: "#/components/schemas/geojsonPolygon"
MultiPolygon: "#/components/schemas/geojsonMultiPolygon"
description: geoJSON geometry
required:
- type
properties:
type:
type: string
enum: [
"Point",
"LineString",
"Polygon",
"MultiPolygon"
]
basePoint:
type: array
minItems: 2
maxItems: 2
items:
type: number
format: float
minimum: 0.0
example: [ 4.53432, 55.324523 ]
geojsonPoint:
type: object
description: Geojson Coordinate
allOf:
- $ref: "#/components/schemas/geojsonGeometry"
- type: object
properties:
coordinates:
$ref: "#/components/schemas/basePoint"
geojsonLine:
type: object
description: An array of WGS84 coordinate pairs
allOf:
- $ref: "#/components/schemas/geojsonGeometry"
- type: object
properties:
coordinates:
type: array
example: [ [ 6.169639, 52.253279 ], [ 6.05623, 52.63473 ] ]
items:
$ref: "#/components/schemas/basePoint"
geojsonPolygon:
type: object
description: geojson representation of a polygon. First and last point must be equal. See also https://geojson.org/geojson-spec.html#polygon and example https://geojson.org/geojson-spec.html#id4. The order should be lon, lat [[[lon1, lat1], [lon2,lat2], [lon3,lat3], [lon1,lat1]]], the first point should match the last point.
allOf:
- $ref: "#/components/schemas/geojsonGeometry"
- type: object
properties:
coordinates:
type: array
example: [ [ [ 1.0, 1.0 ], [ 0.0, 1.0 ], [ 0.0, 0.0 ], [ 1.0,0.0 ], [ 1.0, 1.0 ] ] ]
items:
type: array
example: [ [ 6.169639, 52.253279 ], [ 6.05623, 52.63473 ] ]
items:
$ref: "#/components/schemas/basePoint"
geojsonMultiPolygon:
type: object
description: geojson representation of a multi polygon. See also https://geojson.org/geojson-spec.html#multipolygon
allOf:
- $ref: "#/components/schemas/geojsonGeometry"
- type: object
properties:
coordinates:
type: array
example: [ [ [ [ 1.0, 1.0 ], [ 0.0, 1.0 ], [ 0.0, 0.0 ], [ 1.0,0.0 ], [ 1.0, 1.0 ] ] ] ]
items:
type: array
example: [ [ [ 1.0, 1.0 ], [ 0.0, 1.0 ], [ 0.0, 0.0 ], [ 1.0,0.0 ], [ 1.0, 1.0 ] ] ]
items:
type: array
example: [ [ 6.169639, 52.253279 ], [ 6.05623, 52.63473 ] ]
items:
$ref: "#/components/schemas/basePoint"
Steps to Reproduce
Generate POJOs from TOMP-API.yaml in version 1.6 using openapitools generator in version 7.4.0. Plugin definition from pom:
Hello Adam! We're going to pick up your issue. First, we're going to investigate your solution, since it looks good. I didn't know the 'mapping' construct. On first glance, it might look like a mis-indention in the current situation. Could you easily find out if this is the case? (Add 4 spaces in front of the discriminator labels). Btw I like your solution, I'm seriously going to look at it, use it in V2.0 (or, if it won't break things, in v1.6).
API Version
1.6
Summary
When I generate POJOs using openapitools generator in version 7.4.0 then for GeojsonGeometry object there is no subtypes defined and 'coordinates' property is an empty GeojsonGeometryCoordinates class without any properties inside.
It causes issue when I call e.g. GET operator/stations endpoint:
Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'Point' as a subtype of org.tompapiclient.tompapi.model.GeojsonGeometry: known type ids = [geojsonGeometry] (for POJO property 'stationArea')
It happens because of wrongly defined GeojsonGeometry object, with discriminator on wrong level, without mapping between 'type' enum and subtypes.
Expected Behavior
There should be GeojsonGeometry object generated with proper subtypes (GeojsonPoint, GeojsonLine, GeojsonPolygon, GeojsonMultiPolygon) and every subtype class needs to have 'coordinates' property, since it's specific for the subtype.
Current Behavior
GeojsonGeometry object is generated without sybtypes, with two properties: 'type' and 'coordinates', where 'coordinates' is another empty object (GeojsonGeometryCoordinates).
Possible Solution
The following solution works as expected and doesn't break geojson standard:
Steps to Reproduce
The text was updated successfully, but these errors were encountered: