Giter Club home page Giter Club logo

amf's Introduction

Build Status

AML Modeling Framework

This project aims to provide a common programming interface that lets developers interact with any API specification, whether it is written in OpenAPI Specification (OAS) or RAML, similar to the way the HTML DOM allows programmatic interaction with an HTML document.

Vision

The API Modeling Framework (AMF) allows users to formally describe different kinds of APIs, parse and generate instances of those APIS as sets of modular documents and store those connected descriptions into a single unified data graph.

Goals

  • Support for multiple languages with a unified output API/model for clients
  • Support for both, document (RAML modularity) and domain (service clients), layers
  • Bi-directional transformation
  • Support for validation at document and service layers
  • Produce a formal specification for the language
  • Extensible, single document model for multiple domain vocabularies
  • Consistent parsing behavior

General scope

The library supports many of the required uses cases:

  • Parse a 1.0 RAML, 0.8 RAML, 2.0 OAS and JSON-LD AMF model.
  • AMF API design model creation.
  • Model edition.
  • Export to any of the mentioned standards.

Usage

To use AMF you should first generate or get the right distribution for your project and import them as dependencies.

Installation

Requirements

  • Scala 2.12.2
  • sbt 0.13.15
  • Node

Useful sbt commands

Test

  • Tests on jvm and js
sbt test

Coverage reports

sbt coverage test coverageReport

Generate artifacts directly from cloned repository

sbt package

This will generate jvm JARs in each of the module's targets.

sbt buildJS

This will generate a js artifact in ./file://amf-client/js/amf.js

JVM artifacts

To use, specify dependency.

Gradle example:

dependencies {
    compile 'com.github.amlorg:amf-client_2.12:x.y.z'
}
repositories {
    ...
    maven {
            url 'https://repository-master.mulesoft.org/nexus/content/repositories/releases'
        }
    ...
}

Maven example:

<dependency>
    <groupId>com.github.amlorg</groupId>
    <artifactId>amf-client_2.12</artifactId>
    <version>x.y.z</version>
</dependency>

NOTE: you may use the -SNAPSHOT versions of the JVM artifacts at your own risk since those snapshot versions may contain breaking changes.

JS artifacts

Execute the command

npm install --save amf-client-js

Using Node.js just import it using:

import amf from 'amf-client-js'

The amf package will contain all exported classes:

amf.plugins.document.WebApi.register();
amf.plugins.document.Vocabularies.register();
amf.plugins.features.AMFValidation.register();

amf.Core.init().then(function () {
  // AMF code here
})

Command line usage

You can build a standalone Java executable (JAR) running the following SBT target:

sbt buildCommandLine

This will generate an executable JAR at the top level directory that can be used to execute AMF from the command line.

Using this JAR, you can run tasks from command line, for instance:

java -jar amf-x.y.z.jar parse -in "RAML 1.0" -mime-in "application/yaml" yourAPIfile

or

java -jar amf-x.y.z.jar validate -in "RAML 1.0" -mime-in "application/yaml" -p "RAML" yourAPIfile

or

java -jar amf-x.y.z.jar translate  yourAPIOASfile --format-in "OAS 2.0" -mime-in "application/json" --format-out "RAML 1.0" -mime-out "application/raml+yaml"

To get all available options:

java -jar amf-x.y.z.jar

Using this JAR you can execute AMF by passing one of the following commands:

  • parse <input_file> -in FORMAT
  • translate <input_file> <output_file> -in FORMAT_IN -out FORMAT_OUT
  • validate <input_file> -in FORMAT_IN -p VALIDATION_PROFILE

An interactive section can be started using the repl command.

If you want to parse any RAML dialect other than RAML 1.0, you can pass a list of dialects to be loaded in the parser through the dialects option.

Refer to the usage of the application for additional commands and explanations.

Examples

Go to amf examples repository There are examples for each one of the three usages and a converter project that add some UI on top of the library.

Validation

Validation is one of the key features of AMF. Please check the following link to get more information:

Validation insights

Want to learn more?

Click here for more documentation and playground

Want to contribute?

If you are interested in contributing code to this project, thanks! Please read and accept the Contributors Agreement. This should automatically create a Github issue with the record of your signature here. If for any reason, you do not see your signature there, please contact us.

amf's People

Contributors

agustinbettati avatar antoniogarrote avatar blocklucas avatar eduardo-rubio avatar gbattist avatar gutee avatar jstoiko avatar krishahn avatar looseale avatar nschejtman avatar pcolunga avatar petrochenko-pavel-a avatar pope141 avatar pope1838 avatar suntersa avatar

Watchers

 avatar  avatar  avatar

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.