Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » OpenApi 3 support- generator script
OpenApi 3 support- generator script [message #1834558] Thu, 12 November 2020 12:17 Go to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 131
Registered: December 2015
Senior Member
The 5G_system_TS29571_CommonData protocol module https://git.eclipse.org/r/plugins/gitiles/titan/titan.ProtocolModules.5G_system_TS29571_CommonData_v15 contains a converter script:
tools/OpenApi.py

The OpenApi.py scripts focuses on the yaml definition used in the 5G network function definitions. It contains some optimization for them.

The OpenApi.py creates a TTCN-3 module using the type mapping described here: https://www.eclipse.org/forums/index.php/t/1105886/

Usage:
python3 OpenApi.py <yaml_file>


The uses the following rules;

  • The name of the module is the yaml file name, without the extension
  • import statement are added for every referenced module
  • Encoder/decoder function is defined for every type used in API messages
  • Maps the schemas to TTCN-3 type definition according to the mapping rules with the clarification below.

Type mapping rule clarifications


  • pattern of strings are not mapped.
  • oneOf mapped to union with fields named as field1, field2 etc. The fields are ordered as they appear in the yaml file
  • allOf mapped to set by collecting the fields of from the references. If the allOf can't be resolved then it is mapped to JSON_generic_val
  • string is mapped to charstring
  • Extendable enumeration is converted as the example:
        UpIntegrity:
          anyOf:
            - type: string
              enum:
                - REQUIRED
                - PREFERRED
                - NOT_NEEDED
            - type: string
    

    Converted to:
      type enumerated UpIntegrity_enum { REQUIRED, PREFERRED, NOT_NEEDED}
    
      type union UpIntegrity  {
        UpIntegrity_enum  enum_val,
        charstring  other_val
      } with {
        variant "JSON: as value"
      }
    

  • anyOf is mapped to union
  • TTCN-3 keywords and names are sanitized. The proper encoding attributes are added to the TTCN type definition.


Manual post processing of the generated TTCN-3 module

The OpenApi.py converts only one yaml file at a time. The OpenApi.py creates encoder functions for type defined in another modules. These function declarations should be moved manually to the right module.

[Edit]: allOf support added.

[Updated on: Sat, 14 November 2020 09:10]

Report message to a moderator

Re: OpenApi 3 support- generator script [message #1834563 is a reply to message #1834558] Thu, 12 November 2020 13:15 Go to previous message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Great job, Gabor.

Thank you

Elemer
Previous Topic:OpenApi 3 support
Next Topic:TestPort.PIPEasp
Goto Forum:
  


Current Time: Thu Mar 28 14:01:41 GMT 2024

Powered by FUDForum. Page generated in 0.02587 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top