raml-object-interface

0.1.1 • Public • Published

Raml Object Interface

NPM version NPM downloads Build status Test coverage

An abstract interface to the standard RAML object representation.

Installation

npm install raml-object-interface --save

Usage

var gitHub = new RamlObject(gitHubRaml)

getTitle()

Return the API title string or undefined.

gitHub.getTitle() //=> "GitHub API v3"

getVersion()

Return the API version string or undefined.

gitHub.getVersion() //=> "v3"

getBaseUri()

Return the base uri of the API.

gitHub.getBaseUri() //=> "https://api.gitHub.com"

getMediaType()

Return the global application mediaType string.

gitHub.getMediaType() //=> "application/json"

getProtocols()

Return an array of supported API protocols. Only HTTP or HTTPS.

gitHub.getProtocols() //=> ["HTTPS"]

getSecuredBy()

Return an object describing the different way to handle authentication.

gitHub.getSecuredBy() //=> { "oauth_2_0": { "type": "OAuth 2.0" }, ... }

getDocumentation()

Return the documentation array.

gitHub.getDocumentation() //=> [{ "title": "Home", "content": "..." }, ...]

getBaseUriParameters()

Return a map of named parameters used on the base uri.

gitHub.getBaseUriParameters() //=> { "version": { "type": "string", "default": "v3" }, ... }

getResourceTypes()

Return a map of resource types.

gitHub.getResourceTypes() //=> { "collection": { "get?": null }, ... }

getTraits()

Return a map of traits.

gitHub.getTraits() //=> { "filterable": { "queryParameters": { filter: { ... } } } }

getSecuritySchemes()

Return a map of security scheme objects.

gitHub.getSecuritySchemes() //=> { "oauth_2_0": { "type": "OAuth 2.0", ... } }

getResources()

Return an array of all resource strings.

gitHub.getResources() //=> ["/", "/users", ...]

getResourceChildren(path)

Return an array of valid child resources.

gitHub.getResourceChildren('/') //=> ["/users", ...]

getResourceParent(path)

Return the path of the parent.

gitHub.getResourceParent('/users/{userId}') //=> "/users"

getResourceName(path)

Return a resource name, useful for client generators.

gitHub.getResourceName('/users/{userId}') //=> "userId"

getRelativeUri(path)

Return the relative path to its parent.

gitHub.getRelativeUri('/users/{userId}') //=> "/{userId}"

getRelativeParameters(path)

Return a map of named parameters used on the relative part of the resource.

gitHub.getRelativeParameters('/users/{userId}') //=> { "userId": { ...} }

getResourceMethods(path)

Return an array of support methods of a resource.

gitHub.getResourceMethods('/users') //=> ["get", "post"]

getResourceParameters(path)

Return a map of named parameters used on the resource.

gitHub.getResourceParameters('/users') //=> {}

getMethodHeaders(path, method)

Return a map of named parameters used for the method headers.

gitHub.getMethodHeaders('/users', 'get') //=> { "X-GitHub-Media-Type": { ... }, ... }

getMethodQueryParameters(path, method)

Return a map of named parameters used for the method query parameters.

gitHub.getMethodHeaders('/users', 'get') //=> { "since": { ... }, ... }

getMethodBody(path, method)

Return a map of content type bodies.

gitHub.getMethodBody('/users', 'post') //=> { "application/json": { ... } }

getMethodResponses(path, method)

Return an map of possible responses.

gitHub.getMethodResponses('/users', 'get') //=> { "200": { "body": { "application/json": { ... } } } }

License

Apache License 2.0

Package Sidebar

Install

npm i raml-object-interface

Weekly Downloads

5

Version

0.1.1

License

Apache-2.0

Last publish

Collaborators

  • mulesoft-npm
  • cesaraugustogarcia