Thanks for keeping us posted here!
Here two different movement are colliding. The API movement with the key drivers simplicity and customer centricity and the data-model driven roots of the TMForum APIs.
As everybody may read (https://projects.tmforum.org/wiki/display/AP/API+Data+Model+SID+Mapping+Rules+and+Guideline) the move towards APIs led to a set of rules to simplify (or reduce the feature richness of data modeling) the models to integrate the entities within the APIs. One rule is flattening hierarchies and an other rule states: if an entity only includes metadata (starting with @) the entity should be removed - what is not exactly our case - but showing the importance of metadata.
So if there are reasons to keep these metadata for the client of the data, I do not want continuing arguing. But there are a lot of APIs out there which do not rely on metadata which states the base entity of a structure included in an API. Maybe it helps systems consuming APIs to map these response payloads into their data model. But should they not be able to the same without metadata information?
Open API spec 3.0 somehow heard that users miss inheritance & polymorphism. So allof, oneof, anyof were introduced and even discriminators to identify the field which delivers the type (https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/).
So I stop complaining and offer my help moving to wards Open API 3.0 as a volunteer (if there are activities) - but I am not the born API guy.
Best regards
Michael
P.S.: We are lucky: Polymorphism is allowed in Germany. I checked this.
------------------------------
Michael Frandsen
Vodafone Group
------------------------------
Original Message:
Sent: Oct 17, 2018 02:41
From: Jonathan Goldberg
Subject: Duplicate attributes when using '@'
Reverting to the issue about duplicate field names, @pierre gauthier has indeed confirmed that we should not be using an un-decorated attribute named type in Open API resources. The attribute should be named businessType or <entity>Type or some other name that makes sense in the context of the entity. The decorated @type attribute will stay as part of our support for polymorphism as described in the design guidelines.
------------------------------
Jonathan Goldberg
Amdocs Management Limited
Original Message:
Sent: Oct 16, 2018 16:09
From: Michael Frandsen
Subject: Duplicate attributes when using '@'
Lee,
I did some research. The TMForum APIs are Swagger 2.0 which defined for all objects (including fields) to be JSON compliant. JSON spec (JSON) states that the object/field may be a string which includes all unicode characters.
That is why swagger validators like goswagger.io do not complain about TMForum APIs (like we do ;-).
If TMForum moves to Open API 3.0 they need to follow the specification for Components which helps us because they define a regular expression (^[a-zA-Z0-9\.\-_]+$) for validating field names: OAI/OpenAPI-Specification
This slight difference is not explicitly mentioned in blog posts like A Guide to What's New in OpenAPI 3.0 .
What I do not really understand is, that if you use swaggerhub to migrate an TMForum Open API to 3.0 the "@" remains and no validator complains (I tried swagger ui, swagger inspector and usabillabv/openapi3-validator). So either they did not implement a check using the regular expression or I should not study specifications at the later evening.
@Steve Harrop is quite experienced if it comes to defining interfaces - maybe he can tell us, how it works and maybe if the next generation of APIs may use a smaller set of characters for defining fields.
Best regards
Michael
------------------------------
Michael Frandsen
Vodafone Group
Original Message:
Sent: Oct 15, 2018 03:54
From: Lee Walton
Subject: Duplicate attributes when using '@'
Michael, you closing tag YOGO (You Only Generate Once), is an interesting point.
In the proof of concept I am building, because of the ease with which the Java code can be generated (excluding the @ issue), I've added a Maven project that just builds the API & model classes, and it deliberately does not commit the generated source. So, if another developer checks out the code from git, they too would end up generating the source again. So it is a no go for yogo.
It would be a simple enough matter to change this, so that we only generate once, but I consider this to be somewhat sub-optimal. You should always be able to regenerate the code and use it without modifying it.
If we can address this issue through updating the TM Forum API design guidelines, I do think it would be the best outcome. I really don't like seeing UML models where a special character denotes some kind of additional trait for an entity or attribute, so if we can avoid this, I think it would be the best outcome.
I am also considering forking the swagger.io code generator, to see if we can get the Maven plugin to address this through prefix-replacement, as I am sure that the TM Forum model is not the only model to be affected by these sort of design decisions.
------------------------------
Lee Walton
KCOM Group PLC
Original Message:
Sent: Oct 12, 2018 10:18
From: Michael Frandsen
Subject: Duplicate attributes when using '@'
Hi Lee,
randomly I tried exactly the same with a different API today.
I am not sure if changing the Standard is the best choice.
Changing the generator might need a surgery within the generator framework - So I would go first for fixing the generated files. So you could try to rename the duplicated properties to "atType" (or similar) and see if the "@JsonProperty of the Spring framework will help you to respond "@type".
I'll try the same over the weekend and will state the result here.
Of course correcting generated stuff is not one of the fancy jobs.
Best regards
Michael
P.S.: YOGO! (you only generate once ;-)
Original Message:
Sent: Oct 12, 2018 05:33
From: Lee Walton
Subject: Duplicate attributes when using '@'
I've posted this on the GitHub for the TMF657_ServiceQualityManagement repo on GitHub, but thought it worthy of posting here, as it would impact on the API Design Guidelines.
When generating models using the Swagger definition using the swagger-codegen-maven-plugin
(v2.3.1), there are some entities where the use of the @
to prefix attribute names is causing issues where there is another attribute named the same. eg. on ServiceLevelSpecParameter @type
& type
.
By default, when the model code is generated, in our case into Java, the preceding @
symbol is stripped, resulting in duplicate methods being generated in the code.
So, the use of @
to proceed the attributes is problematic. Would it be possible to review the use of @
to prefix attribute names? Or, should we raise this as an issue with swagger.io
to modify the code generator?
------------------------------
Lee Walton
KCOM Group PLC
------------------------------