Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Derivation from OpenApi Specification(Approach to create a small data type in a Test Description by deriving OpenApi Specification)
Derivation from OpenApi Specification [message #1838118] Tue, 16 February 2021 16:15
Andrej Liebert is currently offline Andrej LiebertFriend
Messages: 18
Registered: January 2021
Junior Member
Hello together,

I want to create a Test Description, written in Test Description Language (TDL), which is coded in Xtext. But I struggle to find an approach to get this task done.

The provided code represents a data object defined in OpenApi Specification and can be easily derived by hand. The current Problem is to translate the provided OpenApi definition to TDL.

In the article https://www.javacodegeeks.com/2018/05/a-guide-to-code-generation.html is mentioned that Xtext, or DSLs in general, can generate code. In addition, Sven Effting mentioned in his Video to Xtext's Introduction many components that could help with the problem (Parser, AST, Code Generator, Interpreter, ...).
It is hard to understand which of those components are needed and which are provided.

For now I want to create a Test Description file (.tdlan2) that takes the OpenApi's definition of components/schemas/ResourceData and translate it to the DSL.

openapi: 3.0.3
info:
  title: 'Example'
  version: '1.0.0'

externalDocs:
  # Reference to the base document
  description: 'ETSI ES 203 647 ...'
  url: 'https://rest.etsi.org'

paths:
[...]

components:
  schemas:
    ResourceData:
      # Structured type
      type: object
      properties:
        # Property name
        id:
          # Property type
          type: string
        size:
          type: string
          enum:
            # Set of allowed values
            - big
            - bigger
            - biggerer
          # Default value for non-required property
          default: big
        created:
          # Date-time value encoded as string
          type: string
          format: date-time
      required:
        # Set of required properties
        - id
[...]


Package ExampleAPI {
    Import all from Standard;
    Import all from HTTP.MessageBased; 
    
    //From Example API specification    
    Type ResourceData extends Body (
      id of type String,
      //can be skipped
      optional ^size of type Integer, 
      //can be skipped 
      optional created of type String  
    );
}
Previous Topic:Unclear (or problematic?) hidden tokens related behaviour
Next Topic:Xtend template error:This expression is not allowed in this context, since it doesn't cause any side
Goto Forum:
  


Current Time: Sat Jul 31 15:54:28 GMT 2021

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

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

Back to the top