All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sinatra.api.mustache Maven / Gradle / Ivy

There is a newer version: 3.0.0-rc1
Show newest version
require 'json'

{{#operations}}
{{#operation}}

MyApp.add_route('{{httpMethod}}', '{{{basePathWithoutHost}}}{{{path}}}', {
  "resourcePath" => "/{{{baseName}}}",
  "summary" => "{{{summary}}}",
  "nickname" => "{{nickname}}", 
  "responseClass" => "{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}", 
  "endpoint" => "{{{path}}}", 
  "notes" => "{{{notes}}}",
  "parameters" => [
    {{#queryParams}}
    {
      "name" => "{{paramName}}",
      "description" => "{{description}}",
      "dataType" => "{{dataType}}",
      "paramType" => "query",
      {{#collectionFormat}}"collectionFormat" => "{{collectionFormat}}",{{/collectionFormat}}
      "allowableValues" => "{{^isContainer}}{{{allowableValues.values}}}{{/isContainer}}",
      {{#defaultValue}}"defaultValue" => "{{{defaultValue}}}"{{/defaultValue}}
    },
    {{/queryParams}}
    {{#pathParams}}
    {
      "name" => "{{paramName}}",
      "description" => "{{description}}",
      "dataType" => "{{dataType}}",
      "paramType" => "path",
    },
    {{/pathParams}}
    {{#headerParams}}
    {
      "name" => "{{paramName}}",
      "description" => "{{description}}",
      "dataType" => "{{dataType}}",
      "paramType" => "header",
    },
    {{/headerParams}}
    {{#bodyParams}}
    {
      "name" => "body",
      "description" => "{{description}}",
      "dataType" => "{{dataType}}",
      "paramType" => "body",
    }
    {{/bodyParams}}
    ]}) do
  cross_origin
  # the guts live here

  {"message" => "yes, it worked"}.to_json
end

{{/operation}}
{{/operations}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy