Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Add more quick starts #16

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tooling/api-console/quick-start/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
publication: 'RAML Playground'
tags: ['RAML', 'Quick Start']
license: 'cc-40-by'
---

# Intro to api-console

This is an introduction to [api-console](https://github.com/mulesoft-labs/api-console-cli). api-console is a tool that generates mobile-friendly web documentation based on RAML documents. In addition to providing documentation, the tool provides the capability for users to try out requests on the fly.

## Install

```sh
$ sudo npm install -g api-console-cli
```

## Run

```sh
$ curl -o api.raml https://raw.githubusercontent.com/raml-org/raml-examples/master/helloworld/helloworld.raml
$ api-console build ./api.raml
$ api-console serve build/
```


NOTE:
Errors using [email protected]. Wait till this bug is fixed https://github.com/mulesoft-labs/api-console-cli/issues/28; Other than that - example works fine (e.g. when using older cli version).
44 changes: 44 additions & 0 deletions tooling/api-spec-converter/quick-start/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
publication: 'RAML Playground'
tags: ['RAML', 'Quick Start']
license: 'cc-40-by'
---

# Intro to API Spec Transformer

This is an introduction to [API Spec Transformer](https://github.com/stoplightio/api-spec-converter). API Spec Transformer is a tool that helps to convert between different API specifications. It currently supports OAS (Swagger 2), RAML 0.8, RAML 1.0, and Postman collections.

## Install

```sh
$ npm install api-spec-transformer
```

## Run

To convert RAML1.0 to OAS (Swagger), download example RAML:

```sh
$ curl -o api.raml https://raw.githubusercontent.com/raml-org/raml-examples/master/helloworld/helloworld.raml
```

Create an `index.js` file with the following code:

```js
const transformer = require('api-spec-transformer')

const ramlToSwagger = new transformer.Converter(
transformer.Formats.RAML10,
transformer.Formats.SWAGGER)

ramlToSwagger.loadFile('./api.raml', (err) => {
ramlToSwagger.convert('yaml')
.then((convertedData) => console.log(convertedData))
})
```

Run it:

```sh
$ node index.js
```
38 changes: 38 additions & 0 deletions tooling/brujula/quick-start/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
publication: 'RAML Playground'
tags: ['RAML', 'Quick Start']
license: 'cc-40-by'
---

# Intro to brujula

This is an introduction to [brujula](https://github.com/nogates/brujula). brujula is a Ruby RAML parser aiming for a full version 1.0 support.

## Install

```sh
$ gem install brujula
```

## Run

Download example RAML:

```sh
$ curl -o api.raml https://raw.githubusercontent.com/raml-org/raml-examples/master/typesystem/simple.raml
```

Create a file called `example.rb` with the following content:

```ruby
require 'brujula'

raml = Brujula.parse_file('api.raml')

puts raml.inspect
puts raml.to_yaml
```

And run it to see RAML being parsed and logged:

<script src="https://gist.github.com/postatum/ffff471dac3d62be27ebce89d2876f20"></script>
35 changes: 35 additions & 0 deletions tooling/godoc2api/quick-start/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
publication: 'RAML Playground'
tags: ['RAML', 'Quick Start']
license: 'cc-40-by'
---

# Intro to godoc2api

This is an introduction to [godoc2api](https://github.com/florenthobein/godoc2api). godoc2api is a command line tool that helps to turn your golang comments into a RAML 1.0 file describing your API.

## Install

```sh
$ go get github.com/florenthobein/godoc2api
```

## Run

Create a file named `main.go` with the following code (note comments):

<script src="https://gist.github.com/postatum/36e66baa6482986d2ad2bf5e4cf4e446"></script>

Run it with `go run main.go`, then stop the server. Now you should see generated RAML file at `./raml/your_api_v1.raml` with a similar content:

```raml
#%RAML 1.0
---
title: Your API
version: v1
baseUri: http://localhost:3000
mediaType: application/json
/dogs:
get:
description: An endpoint that just says something about dogs
```
40 changes: 40 additions & 0 deletions tooling/jsonapi2raml/quick-start/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
publication: 'RAML Playground'
tags: ['RAML', 'Quick Start']
license: 'cc-40-by'
---

# Intro to jsonapi2raml

This is an introduction to [jsonapi2raml](https://github.com/tabone/jsonapi2raml). jsonapi2raml is a thin wrapper around raml-js-parser-2, adding extra properties to the resulting object. Features:
* Restructures types from [{typeA: {...}}, ...] to {typeA: {}, ...}

## Install

```sh
$ npm install jsonapi2raml -g
```

## Run

Download example JSON API payload file:

```sh
$ curl https://gist.githubusercontent.com/postatum/2bdba245ceabe5837bf3c2d4c0f23ad8/raw/9355778cb61e33d965d2d6d3efd37713cecbff0a/payload.json
```

Now let's generate RAML 1.0 documentation:

```sh
$ jsonapi2raml payload.json usersApi
```

This will generate big `usersApi.raml` file. You could check out it in your editor or just check it's content with `cat` and `grep` to see that routes were generated:

```sh
$ cat usersApi.raml | grep user
type: "user"
type: "user"
type: "user"
/user:
```
2 changes: 1 addition & 1 deletion tooling/oas-raml-converter/quick-start/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $ oas-raml-converter --from RAML --to OAS30 ./api.raml > api.oas3
```

## Using `oas-raml-converter` as a NodeJS library
`oas-raml-converter` can also be used as a library! This is particularly useful when processing either the input or the output. Let's see how it works.
`oas-raml-converter` can also be used as a library! This is particularly useful when processing either the input or the output. Let's see how it works.

In this scenario, I'll use `oas-raml-converter` to convert from RAML 1.0 to OAS 2.0, and then, use `yamljs` to convert the output to the YAML syntax.

Expand Down
76 changes: 76 additions & 0 deletions tooling/raml-cli/quick-start/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
publication: 'RAML Playground'
tags: ['RAML', 'Quick Start']
license: 'cc-40-by'
---

# Intro to raml-cli

This is an introduction to [raml-cli](https://github.com/raml-org/raml-cli). raml-cli is a handy command-line tool for RAML enthusiasts. It's features include:
* Validation of a root RAML document against the specification;
* Compilation of a root RAML document into a valid OpenAPI 2.0 document;
* Initialization of a basic RAML document based on user input;
* Mocking of a root RAML document.

## Install


```sh
$ npm install -g raml-cli
```

## Run

Download example RAML:

```sh
$ curl -o api.raml https://raw.githubusercontent.com/raml-org/raml-examples/master/typesystem/simple.raml
```

1. Validate a root RAML document against the specification:

```sh
$ raml validate api.raml
Validating api.raml...
Valid!
```

2. Compile a root RAML document into a valid OpenAPI 2.0 document:

```sh
$ raml compile api.raml
Compile api.raml...
Successfully compiled OAS 2.0 document.
```

New file called `openapi.yml` should appear with the following content:

<script src="https://gist.github.com/postatum/83ab380edb43924854f57a5bd32b6965"></script>

3. Initialize a basic RAML document based on user input:

```sh
$ raml init
init...
? What is the title of your API? (empty string is not allowed): Dogs API
? How would you describe your API? (Enter to skip): Greatest API ever
{ title: 'Dogs API', description: 'Greatest API ever' }
Initialization successful!

$ cat api.raml
#%RAML 1.0
title: Dogs API
description: Greatest API ever
```

4. Mock a root RAML document (re-download example RAML first):

```sh
$ raml mock api.raml
Mock service running at http://localhost:8080

$ http http://localhost:8080/users/1
HTTP/1.1 200 OK
Content-Type: application/json
(...)
```
45 changes: 45 additions & 0 deletions tooling/raml-js-parser-2/quick-start/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
publication: 'RAML Playground'
tags: ['RAML', 'Quick Start']
license: 'cc-40-by'
---

# Intro to raml-1-parser

This is an introduction to [raml-1-parser](https://github.com/raml-org/raml-js-parser-2). raml-1-parser is a JavaScript RAML parser that supports both RAML 0.8 and 1.0.

## Install

```sh
$ npm install raml-1-parser
```

## Run

Download example RAML:

```sh
$ curl -o api.raml https://raw.githubusercontent.com/raml-org/raml-examples/master/helloworld/helloworld.raml
```

Create new file `index.js` with the following code:

```js
const raml = require('raml-1-parser')
raml.load('./api.raml').then((apiJSON) => {
console.log(JSON.stringify(apiJSON, null, 2))
})
```

Run it with:

```sh
$ node ./index.js
```

Parsing can also be performed synchronously:
```js
const raml = require('raml-1-parser')
const apiJSON = raml.loadSync('./api.raml')
console.log(JSON.stringify(apiJSON, null, 2))
```
35 changes: 35 additions & 0 deletions tooling/ramlo/quick-start/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
publication: 'RAML Playground'
tags: ['RAML', 'Quick Start']
license: 'cc-40-by'
---

# Intro to ramlo

This is an introduction to [ramlo](https://github.com/PGSSoft/ramlo). ramlo is a command line tool based on Node.js for generating RESTful API documentations written in RAML.

## Install

```sh
$ npm install -g ramlo
```

## Run

Download example RAML:

```sh
$ curl -o api.raml https://raw.githubusercontent.com/raml-org/raml-examples/master/typesystem/simple.raml
```

Run the command to generate documentation:

```sh
$ ramlo -f api.raml
```

Now you can browse the generated html:

```sh
$ browse index.html
```