TOMP-WG / TOMP-API

Transport Operator to Mobility-as-a-Service Provider-API development for Mobility as a Service
Apache License 2.0
100 stars 41 forks source link

[BUG] bad modeling of maps like assetTypesAvailable #503

Closed CarloMendola closed 11 months ago

CarloMendola commented 1 year ago

API Version

1.4.0

Summary

since version 1.4.0 there are few attributes to count resources available e.g. stationInformation

Expected Behavior

All these attributes are described in examples as maps e.g. assetTypesAvailable: { "child-bike-01": 1, "general-bike": 3 }

Current Behavior

within the design swagger all those attributes are modeled as arrays of maps e.g. stationInformation: .........omissis....... assetTypesAvailable: type: array description: An object used to describe the available assets of a station where each key is a reference to the ID of the assetType, and the value is a number representing the total available asset of this type at this station. items: type: object additionalProperties: true example: { "child-bike-01": 1, "general-bike": 3 }

The given example is not compliant to the attribute definition, there's no array.

Possible Solution

All these kind of attributes are obviously maps, and array shall be removed from definition.

Steps to Reproduce

If I use swagger codegen to generate models from openapi I have as follows: @JsonProperty("assetTypeCapacity") @Valid private List<Map<String, Object>> assetTypeCapacity = null;

Context (Environment)

Validated models from openapi with codegen java -Xmx512m -jar swagger-codegen-cli-3.0.34.jar generate -i openapi.yaml -c config.json -l spring -DhideGenerationTimestamp=true -o "out"

Detailed Description

Possible Implementation

openapi models shall be updated breaking backward compatibility to describe just objects with additional properties instead of arrays

edwinvandenbelt commented 1 year ago

I think you're completely right. We cannot address it in version 1.5... We still can request an 1.4.1, with this issue addressed as a bug-fix.

It should be: assetTypesAvailable: type: object description: An object used to describe the available assets of a station where each key is a reference to the ID of the assetType, and the value is a number representing the total available asset of this type at this station. additionalProperties: true example: { "child-bike-01": 1, "general-bike": 3 }

edwinvandenbelt commented 1 year ago

Version 1.4.1 is created and updated. Please verify if it is correct.