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: 86
Registered: December 2015
The 5G_system_TS29571_CommonData protocol module contains a converter script:

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

The creates a TTCN-3 module using the type mapping described here:

python3 <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:
            - type: string
                - 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 converts only one yaml file at a time. The 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

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

Current Time: Tue Jun 22 02:26:34 GMT 2021

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

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

Back to the top