Git Product home page Git Product logo

rest-modeling-framework's Introduction

The rest modeling framework provides an EMF based model for RAML api definition files.

Using in your own project

The latest unstable release can be retrieved from Maven with:

ext {
    rmfVersion = "0.2.0-20240119124459"
}

sourceCompatibility = 1.8

dependencies {
    compile "com.commercetools.rmf:raml-model:${rmfVersion}"
}

The main entry point is the io.vrap.rmf.raml.model.RamlModelBuilder class, see the following code for an example on how to use it:

  final URI fileURI = URI.createFileURI("/path/api.raml");
  final RamlModelResult<Api> modelResult = new RamlModelBuilder().buildApi(fileURI);
  final List<RamlDiagnostic> validationResults = modelResult.getValidationResults();

  if (validationResults.isEmpty()) {
      final Api api = modelResult.getRootObject();
  }  

Docker

To start the RMF generator using docker use the following command

docker run --rm -v<RAML-definition-directory>:/api -v<output-directory>:/out vrapio/rmf-generator -l postman /api/update-actions.raml

rest-modeling-framework's People

Contributors

adrobisch avatar jenschude avatar katmatt avatar zombieleet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rest-modeling-framework's Issues

Upgrade gradle version

We should update our gradle version to the latest version.

  • fix bootstrap classpath issue
  • fix bintrayUpload

Expose method to parse a type expression

It would be nice if we could provide a helper method to parse type expression (e.g. MyType[] or MyType | yourType) and resolve it against the current API.

Usecase is that we want to use type expressions in annitations.

Replace Property with Type

Our current ObjectType models its properties with a separate Property type. This isn't following the RAML spec which uses types for the properties. I had doubts in the beginning if I really liked to reuse Type for them, but with our experience now it seems to be better to remove our Property type and replace it with Type.

This change has a big impact on our codegenerator and updating to this fix will take some time.

Add getParent method

Every type in our model should provide the following two methods

<T> T getParent(Class<T> type)
<T> T getParent(Class<T> type, Predicate<T> filter)

Improve creation of UnionType

For an union type with multiple types, our parser builds a chain of union types. It would be better to just create a list of the types.

Issue on enum definition

When using an enumeration with on off values, for example as follows

ImageSearchConfigStatus:
    type: string
    enum:
        - on
        - off

i get the following error Enum facet contains duplicate values
this seems weird as if the parser consider them the same value.
any ideas what might be the issue here @katmatt @jenschude ?

Find a new JS script engine

Newer JDK versions don't ship anymore with a javascript script engine and this then breaks the runtime of RMF. We should find a replacement for it and it as a dependency to RMF - instead of relying that the JDK provides it.

Improve validation

Looks like our current validation has the following issues:

  • ignores errors in used libraries
  • doesn't validate enum values on inline types

Multi-inheritance validation

Hi @jenschude, thanks for this framework, I think it is great. We are using it now in https://github.com/commercetools/scraml to generate types in sbt.
I stumbled upon In fd6865f when I tried to create a hierarchy of types:

type A
type B
type C extends B, C

B, C and are basically marker interfaces and do not have their own properties or only non-conflicting ones.

In the RAML:

type: [A, B]

While debugging it appeared to me that the resulting type was actually correct for what I was trying to model, giving me an Intersection type with the two types but the TypeConsistencyCheck was throwing an error.

The check seems to be broader than the actual fix, as it is not considering the container type being property and the ignored tests suggest that this was really a quick hack. Any chance this can be revisited again?

Example use within Eclipse

Is there an example on how to use this component within Eclipse, as a P2 or similar? It seems the model registers extension points, but what about resource factories.

Annotation enum value isn't vaidated against annotation type

Example:

annotationTypes:
  ReferenceType:
    description: |
      This annotation documents the type of an import reference.
    type: string
    enum:
      - category
types:
  MyType:
    (ReferenceType): product

should report an invalid enum value. But doesn't report it.

Support reserved keywords in names

Issue #30 revealed the more generic problem that most of our names in our ANTLR grammar don't support reserved keywords. They're using the SCALAR token instead of the id rule. We should write more tests and fix our grammar appropriately.

Add description attribute to TypedElement

If a TypedElement has a description facet, we will always create an inline type with this description. It would be better to add a description attribute to TypedElement instead of adding it to the inline type.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.