Derivation from OpenApi Specification [message #1838118] |
Tue, 16 February 2021 16:15 |
Andrej Liebert 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
);
}
|
|
|
Powered by
FUDForum. Page generated in 0.02041 seconds