• This repository has been archived on 20/Jan/2024
  • Stars
    star
    200
  • Rank 188,488 (Top 4 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 10 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Community-maintained RAML parser for php

Build Status Coverage Status Latest Stable Version Total Downloads

See the RAML specification.

RAML 0.8 Support

For RAML 0.8 support follow version 2.

RAML 1.0 Support

For RAML 1.0 support follow version 3 or above. RAML 1.0 support is still work in progress.

What is done and should work:

  • Part of RAML 1.0 type expressions
  • Enums
  • Union type expression (the "or" | operator)
  • Array of types
  • discriminator and discriminatorValue facets
  • Traits inheritance

To be implemented:

Get started

Requires:

composer require raml-org/raml-php-parser
$parser = new \Raml\Parser();
$apiDef = $parser->parse($filename, true);

$title = $apiDef->getTitle();

Parsing schemas

The library can convert schemas into an validation object. There is a default list, or they can be configured manually. Each schema parser needs to conform to Raml\Schema\SchemaParserInterface and will return a instance of Raml\Schema\SchemaDefinitionInterface.

Additional parsers and schema definitions can be created and passed into the Raml\Parser constructor

Exporting routes

It is also possible to export the entire RAML file to an array of the full endpoints. For example, considering a basic RAML, this can be returned using:

$parser = new \Raml\Parser();
$api = $parser->parse('tests/fixture/simple.raml');

$routes = $api->getResourcesAsUri();

To return:

[
    GET /songs => ...
    POST /songs => ...
    GET /songs/{songId} => ...
    DELETE /songs/{songId} => ...
]

$routes = $api->getResourcesAsUri(new \Raml\RouteFormatter\NoRouteFormatter());

Route Formatters

There are two Route Formatters included in the package:

  • NoRouteFormatter which does nothing and simply echoes the result
  • SymfonyRouteFormatter which adds the routes to a Symfony RouteCollection

Contributing

composer run-static-analysis
composer check-code-style
composer run-tests

More Repositories

1

raml-spec

RAML Specification
3,862
star
2

raml-js-parser

(deprecated) A RAML parser based on PyYAML written in CoffeScript and available for use as NodeJs module or in-browser.
JavaScript
195
star
3

raml-examples

This repository contains valid RAML 1.0 examples. These examples are not only part of the spec, but also represent RAML features in different scenarios.
RAML
192
star
4

raml-java-parser

(deprecated) A RAML parser based on SnakeYAML written in Java
Java
175
star
5

raml-js-parser-2

(deprecated)
RAML
139
star
6

webapi-parser

API Spec parser based on AMF. Currently supports RAML 0.8, RAML 1.0, OAS 2.0 and OAS 3.0(beta).
Scala
64
star
7

ramldt2jsonschema

CLI & Library to convert a RAML 1.0 data type to a JSON Schema, and back
JavaScript
58
star
8

api-modeling-framework

DEPRECATED - This project has been moved
Clojure
27
star
9

raml-dotnet-parser

Community-maintained .NET parser for RAML
C#
23
star
10

raml-java-parser-2

JavaScript
19
star
11

raml-dotnet-parser-2

RAML
18
star
12

raml-typesystem

(deprecated) Typescript implementation of RAML type system
TypeScript
15
star
13

raml-org

Project website
SCSS
14
star
14

raml-cli

A handy command-line tool for RAML enthusiasts.
TypeScript
11
star
15

raml-tutorial-08

DEPRECATED - This repository contains the content for the RAML tutorial on raml.org.
9
star
16

raml-tck

Test Compatibility Kit for RAML 1.0
RAML
8
star
17

playground

RAML Playground (WIP)
TypeScript
7
star
18

raml-by-example

Series of examples leveraging tools of the RAML community
RAML
6
star
19

datatype-expansion

(deprecated) Utility tool to expand a given RAML type and create a canonical form
JavaScript
6
star
20

raml-definition-system

(deprecated) Definition System for RAML 0.8/1.0
TypeScript
3
star
21

raml-annotations

This repository contains a number of annotations that we, as a community, agreed on and share for others to use.
RAML
2
star
22

raml-tck-runner

Run several RAML parsers against RAML TCK
JavaScript
1
star