Open adamtomecki opened 5 months ago
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).
Patched it! Your solution was very good! I didn't know the 'mapping' construct. I will apply it in v2.0 as well! Could you test it? @adamtomecki
@edwinvandenbelt Hi Edwin, it looks very good, thank you for resolving that!
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
Generate POJOs from TOMP-API.yaml in version 1.6 using openapitools generator in version 7.4.0. Plugin definition from pom:
[ { "stationId": "XX:Y:12345678", "name": "IslandCentral", "contactPhone": "string", "coordinates": { "lng": 6.169639, "lat": 52.253279, "alt": 0 }, "physicalAddress": { "streetAddress": "examplestreet18,2ndfloor,18-B33", "street": "string", "houseNumber": 0, "houseNumberAddition": "string", "addressAdditionalInfo": "string", "areaReference": "Smallcity,Pinetreecounty", "city": "string", "province": "string", "state": "string", "postalCode": "string", "country": "NL" }, "crossStreet": "onthecornerwithSecondaryRoad", "regionId": "string", "stationArea": { "type": "Point", "coordinates": [ 4.53432, 55.324523 ] }, "parkingType": "PARKING_LOT", "isVirtual": true, "isValetStation": true, "isChargingStation": true, "parkingHoop": true, "isInstalled": true, "isRenting": true, "isReturning": true, "capacity": 0, "assetTypeCapacity": { "child-bike-01": 3, "general-bike": 18 }, "assetsAvailable": 0, "assetTypesAvailable": { "child-bike-01": 1, "general-bike": 3 }, "docksAvailable": 0, "assetDocksAvailable": { "child-bike-01": 1, "general-bike": 3 }, "rentalMethods": [ "CREDITCARD", "PAYPASS", "APPLEPAY" ], "rentalMethodOther": "iDEAL" } ]