[NETCONF-1124] OpenApi: Improve union type processing Created: 08/Aug/23  Updated: 15/Aug/23  Resolved: 15/Aug/23

Status: Resolved
Project: netconf
Component/s: restconf-openapi
Affects Version/s: None
Fix Version/s: 7.0.0

Type: Task Priority: Medium
Reporter: Ivan Hrasko Assignee: Matej Šramčík
Resolution: Done Votes: 0
Labels: pt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Instead of introducing cumbersome logic for union processing, process its default type or choose first one.



 Comments   
Comment by Ivan Hrasko [ 15/Aug/23 ]

Current logic present in DefinitionGenerator#processUnionType has no clue about the type of default value anyway.

What is done there is:

  • check for string, boolean or number type in a cycle
  • as a consequence we can have as a result string, boolean and number at the same time
  • what is correct because that the nature of union
  • then we are trying to cast default value to some type preferring string - what is not correct

I propose to delete DefinitionGenerator#processUnionType, use first member type for generating example and omitting default value at all.

Generated at Wed Feb 07 20:16:44 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.