You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 21, 2024. It is now read-only.
*[Resolving an API Spec](https://raml-org.github.io/webapi-parser/common/resolution)
20
-
*[Navigating an API Spec](https://raml-org.github.io/webapi-parser/common/model-navigation)
21
-
*[Constructing an API Spec](https://raml-org.github.io/webapi-parser/common/api-construction)
22
-
* Translating/converting API Spec formats:
23
-
*[RAML Data Type -> JSON Schema conversion](https://raml-org.github.io/webapi-parser/common/conversion-raml-json)
24
-
*[JSON Schema -> RAML Data Type conversion](https://raml-org.github.io/webapi-parser/common/conversion-json-raml)
18
+
## Examples
19
+
*[Resolving a "WebApi" Model](https://raml-org.github.io/webapi-parser/resolving)
20
+
*[Navigating a "WebApi" Model](https://raml-org.github.io/webapi-parser/navigating)
21
+
*[Constructing a "WebApi" Model](https://raml-org.github.io/webapi-parser/constructing)
22
+
*[Translating RAML DataTypes to JSON Schemas](https://raml-org.github.io/webapi-parser/translating-raml-json)
23
+
*[Translating JSON Schemas to RAML DataTypes](https://raml-org.github.io/webapi-parser/translating-json-raml)
25
24
26
25
## Installation
27
26
@@ -32,15 +31,15 @@ Install the npm package:
32
31
$ npm install webapi-parser
33
32
```
34
33
35
-
and then require/reference as follows:
34
+
and require/reference as follows:
36
35
```js
37
36
constwap=require('webapi-parser').WebApiParser
38
37
```
39
38
40
-
You can check the [JavaScript examples directory](https://github.com/raml-org/webapi-parser/tree/master/examples/js/) for some usage examples.
39
+
See the [JavaScript examples directory](https://github.com/raml-org/webapi-parser/tree/master/examples/js/) for some usage examples.
41
40
42
41
### Java
43
-
To use, you'll need to specify`webapi-parser` as a dependency and set both MuleSoft and Jitpack repositories.
42
+
Specify`webapi-parser` as a dependency and set both MuleSoft and Jitpack repositories.
44
43
45
44
Gradle:
46
45
```groovy
@@ -79,7 +78,7 @@ Maven:
79
78
</repositories>
80
79
```
81
80
82
-
You can check the [Java examples directory](https://github.com/raml-org/webapi-parser/tree/master/examples/java/) for some usage examples.
81
+
See the [Java examples directory](https://github.com/raml-org/webapi-parser/tree/master/examples/java/) for some usage examples.
83
82
84
83
---
85
-
If you wish to contribute to this project, see our [Contribution Guidelines](https://github.com/raml-org/webapi-parser/tree/master/CONTRIBUTING.md).
84
+
If you wish to contribute to this project, please review our [Contribution Guidelines](https://github.com/raml-org/webapi-parser/tree/master/CONTRIBUTING.md).
Copy file name to clipboardExpand all lines: docs/constructing.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# API construction
1
+
# Constructing a "WebApi" Model
2
2
Using `webapi-parser` it is possible to construct an API in all supported formats by hand. These construction methods can also be used to edit a parsed document.
3
3
4
4
Below is a simplified example of constructing RAML 1.0 API.
Copy file name to clipboardExpand all lines: docs/navigating.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# WebApi Model navigation
1
+
# Navigating a "WebApi" Model
2
2
Using `webapi-parser` it is possible to navigate parsed document and extract data like response codes, titles, descriptions, data types, etc., from it.
3
3
4
4
Below is a simplified example of navigating RAML 1.0 API.
Copy file name to clipboardExpand all lines: docs/resolving.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Resolution
1
+
# Resolving a "WebApi" Model
2
2
This document describes `webapi-parser` process called "resolution". This process is performed by syntax-specific `.resolve()` methods of all supported API syntaxes (RAML, OAS, AMF Graph).
Copy file name to clipboardExpand all lines: docs/translating-json-raml.md
+10-14
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,10 @@
1
-
# JSON Schema -> RAML Data Type conversion
2
-
Using `webapi-parser` and [WebApi Model](https://raml-org.github.io/webapi-parser/js/classes/_webapi_parser_.webapibaseunit.html), it is possible to convert JSON Schemas to RAML Datatypes.
1
+
# Translating JSON Schemas to RAML DataTypes
2
+
Using `webapi-parser` and [WebApi Model](https://raml-org.github.io/webapi-parser/js/classes/_webapi_parser_.webapibaseunit.html), it is possible to translate JSON Schemas to RAML Datatypes.
3
3
4
-
Please refer to [complete examples](#complete-examples) for more advanced usecases.
4
+
You can take a look at the [complete examples](#complete-examples) for more advanced use-cases.
5
5
6
6
## Quick start
7
-
8
-
To convert JSON Schema to RAML Data Type, parse the document of your choice, reach data type using WebApi Model and call its `.toRamlDatatype()` method (or property in JS case). Output of the method is RAML 1.0 Library string containing converted type.
9
-
10
-
To convert plain JSON Schema string to RAML DataType it has to be wrapped in a OAS 2.0 document.
7
+
To translate a JSON Schema to a RAML DataType, you can parse a JSON containing one or more JSON Schemas, then select the data type/schema using the [WebApi Model](https://raml-org.github.io/webapi-parser/js/classes/_webapi_parser_.webapibaseunit.html) and call its `.toRamlDatatype()` method (or property in JavaScript). The output of the method is a RAML 1.0 Library string containing the translated type. Note that the JSON Schema must be wrapped in an OAS 2.0 document.
Using `webapi-parser` and [WebApi Model](https://raml-org.github.io/webapi-parser/js/classes/_webapi_parser_.webapibaseunit.html) it is possible to convert RAML 1.0 Data Type from RAML 1.0 API, RAML 1.0 Library or RAML 1.0 DataType Fragment to corresponding JSON Schema.
1
+
# Translating RAML DataTypes to JSON Schemas
2
+
Using `webapi-parser` and [WebApi Model](https://raml-org.github.io/webapi-parser/js/classes/_webapi_parser_.webapibaseunit.html), it is possible to translate RAML 1.0 DataTypes contained inside RAML 1.0, RAML 1.0 Library and RAML 1.0 DataType documents to JSON Schemas.
3
3
4
-
Please refer to[complete examples](#complete-examples) for more advanced use cases.
4
+
You can take a look at the[complete examples](#complete-examples) for more advanced use cases.
5
5
6
6
## Quick start
7
-
8
-
To convert RAML Data Type to JSON Schema, parse RAML document, reach data type using WebApi Model and call its `.toJsonSchema()` method (or property in JS case). Output of the methods is JSON Schema string of converted type.
7
+
To translate a RAML DataType to a JSON Schema, you can parse a RAML document, then select the data type using [WebApi Model](https://raml-org.github.io/webapi-parser/js/classes/_webapi_parser_.webapibaseunit.html) and call its `.toJsonSchema()` method (or property in JavaScript). The output of the method is a JSON Schema string representating the original RAML DataType.
9
8
10
9
```js
11
10
// js
@@ -23,9 +22,10 @@ const ramlLibrary = `
23
22
24
23
asyncfunctionmain () {
25
24
constlibModel=awaitwap.raml10.parse(ramlLibrary)
26
-
//Convert type from root. Type can be picked using utility functions
25
+
// Type can be selected using the utility function `getDeclarationByName()`
0 commit comments