Skip to content

Latest commit

 

History

History
103 lines (58 loc) · 2.04 KB

nim_generator.md

File metadata and controls

103 lines (58 loc) · 2.04 KB

Nim Code Generator

Server

Generated server code uses jester as web framework.

Client

Generated client library uses httpclient module from stdlib

Type

RAML Object usually become Nim Object

Scalar Type Mapping

Raml        |  Nim 
----------- | -----------
string      | string
number      | float64
integer     | int
boolean     | bool
date        | Time
enum        | enum
file        | string
Array       | sequence
Union       | -

Input Validation

TBD

Bodies

Request and response body are mapped into structs and following the same rules as types.

struct name = [Resource name][Method name][ReqBody|RespBody].

Resources and Nested Resources

Server

Resources in the server are mapped to:

  • routes in main file:

  • API implementation that implements the resource. One file for each root resource

Client

Resourcess in the client are implemented as services.

Let's say we have two root resources:

  • /users
  • /network

Client library is going to have two services:

  • Users
  • Network

Each service will have it's own methods

Methods

Header

TBD

Query Strings and Query Parameters

All client library functions have arguments to send query strings and query Parameters.

Responses

Resource Types and Traits

Resource Types and Traits already parsed by the parser. So, the generator need to know nothing about it.

Security Schemes

go-raml only supports OAuth2.0.

  • client : it currently able to get oauth2 token with client credentials.
  • server : it currently only support JWT token.

Annotations

Modularization

Includes

Includes should work properly

Libraries

Overlays and Extensions