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

ruby-sinatra-server.api.mustache Maven / Gradle / Ivy

There is a newer version: 7.6.0
Show newest version
require 'json'

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

MyApp.add_route('{{httpMethod}}', '{{{basePathWithoutHost}}}{{{path}}}', {
  "resourcePath" => "/{{{baseName}}}",
  "summary" => "{{{summary}}}",
  "nickname" => "{{nickname}}",
  "responseClass" => "{{{returnType}}}{{^returnType}}void{{/returnType}}",
  "endpoint" => "{{{path}}}",
  "notes" => "{{{notes}}}",
  "parameters" => [
    {{#queryParams}}
    {
      "name" => "{{paramName}}",
      "description" => "{{description}}",
      "dataType" => "{{{dataType}}}",
      {{#collectionFormat}}
      "collectionFormat" => "{{.}}",
      {{/collectionFormat}}
      {{^isContainer}}
      "allowableValues" => "{{{allowableValues.values}}}",
      {{/isContainer}}
      {{#defaultValue}}
      "defaultValue" => "{{{.}}}",
      {{/defaultValue}}
      "paramType" => "query",
    },
    {{/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