This document contains the most important information for developers who want to understand and extend RAMA.
Description of the tools behavior if it is started via command-line.
Entry point of the tool. Command-line options are detected and passed to the ApplicationService
.
The ApplicationService
is responsible for creating:
RestfulSystem
RestfulService
Evaluation
Measurement
Class | Responsibility |
---|---|
RestfulSystem |
One system can consist of multiple services. This entity is used to store the system name and a list of RestfulServices . This is not used in the CLI. Can be used in combination with the other tools. |
RestfulService |
Represents a single specification file. Can store meta data like a name or the file URL. Also stores a list of Evaluations . This entity is later used by the RestfulServiceMapper to generate PDF or JSON files. |
Evaluation |
Contains multiple Measurements and also other meta data. |
Measurement |
Represents the concrete values for a single metric. |
All Parsers inherit from the Parser.java
class.
The Parser are responsible for transforming specification files from each format to our Internal API Model
Each parser has to parse a given API specification into the internal model for the evaluation. The internal model consists of the following 11 classes.
SpecificationFile
: Contains the meta-information of the file.SpecificationDescriptor
: Contains the format and the version of the format of the file.API
: Contains the basePath
and aPath
for each individual endpoint of the API.Path
: APath
object contains the name of the path and a list of all methods the endpoint provides.Method
: EachMethod
object should have its HttpMethod defined and contains a list of allParameters
,Responses
andRequestBodies
it contains. Additionally, anoperationID
must be provided. Should the API specification language not require aoperationID
, you can use an incrementing integer for this variable.Parameter
: AParameter
object should provide its name as the key (the same value that has been used as key in theParameter
map), the data type of theParameter
, where theParameter
was specified and if it is required or not.Response
: EachResponse
object contains the codes for which theResponse
is send and the possible content media types contained in theResponse
.RequestBody
: EachRequestBody
object has all the possibleContentMediaTypes
it contains.ContentMediaType
: EachContentMediaType
object has its media type as a String and aDataModel
object.DataModel
: ADataModel
object has a data type which is usually either object or array, a map ofProperties
contained in it, aDataModelRelationship
object and a list of childDataModel
objects.DataModelRelationship
is required if the data schema uses a modifier likeoneOf
,allOf
, oronlyOne
.Property
: AProperty
has its name as a key (the same value that has been used as key in theProperties
map), theDataType
of the property, the format of the property, a list of childProperty
objects and it can also contain aDataModel
object.Properties
which themselves contain more properties have to be listed under sub properties as well. Furthermore, a property contains aboolean
which defines whether or not this property can be null and the twoint
valuesminOccurs
andmaxOccurs
. TheDataModel
of aProperty
is used when it is defined by a schema that usesoneOf
,allOf
, oronlyOne
.
To add a new parser, create a new class that inherits from the abstract Parser.java
class. The Parser
class provides the two methods loadPublicUrl
and loadLocalUrl
, which return a SpecificationFile
object. At least one of these methods should be overridden and used as an entry point for the parser. Furthermore, the Parser
has to parse all relevant information of the given API specification into the returned SpecificationFile object. Lastly, the ParserType.java
has to extended with a new ENUM
and a new case
has to be added to the switch
statement.
The tool currently has 3 parsers that are described as follows:
To extend the tool with additional metrics, create a new class that implements the IMetric
interface. The interface contains all methods expected by the tool. JUnit tests for new metrics should also be implemented and all required specification files for a specific metric test should be copied in a new src/test/resources/metrics/...
folder so that it is easier to maintain metrics.
In order to use the available web-app-api
project as a backend for the Vue.js frontend, make sure that each new metric also has an ini
file in the src\main\resources\metric-ini
folder. Four keys for the [thresholds]
section and one for the [colorDistribution]
section are expected. In [thresholds]
, set the keys for the absolute color scheme used in the frontend. The lower and upper bound of the colors red and green are to be determined. The boolean
key maxGreen
in [colorDistribution]
determines if the highest value is presented green and the lowest value is presented red or vice versa.
To modify the internal model, the ProtoBuf file in src/main/proto
has to be adjusted. While new properties can simply be inserted, a new class has to be defined as a new message. The official language guide is a more elaborate starting point to familiarize yourself with ProtoBuf. Currently the proto sources have to be compiled manually, which is done by invoking the Protocol Compiler as follows:
protoc --proto_path=./src/main/proto --java_out=./src/main/java model.proto
At a later point, this build process should probably be automated via Maven.
The generated Java class holds Builder
factories for all defined messages with the appropriate getters and setters. After an object has been built, it has to be casted back to a builder to allow for further modifications. The official tutorial is more exhaustive.
It is strongly advised to check all existing metrics for needed adjustments and especially incorporate the updated model into all implemented parsers. Changes to the internal data model technically necessitate adjustments to either parsers or metrics. Only a rigorous checking will maintain the correctness of calculated metrics.
The implemented metrics are documented here.
TODO