Templates · Example Payload

Templates Mustache Api Example

Example of a Mustache template variable context for generating an OpenAPI-based REST API client

TemplatesAPI DesignCode GenerationDocumentationOpenAPIAsyncAPI

Templates Mustache Api Example is an example object payload from Templates, with 5 top-level fields. It illustrates the shape of data this provider's APIs accept or return.

Top-level fields

descriptionenginetemplateFilecontextrenderedOutput

Example Payload

templates-mustache-api-example.json Raw ↑
{
  "description": "Example of a Mustache template variable context for generating an OpenAPI-based REST API client",
  "engine": "mustache",
  "templateFile": "api-client.mustache",
  "context": {
    "apiName": "PetStore API",
    "packageName": "petstore-client",
    "version": "1.0.0",
    "baseUrl": "https://api.petstore.example.com/v1",
    "authType": "bearer",
    "operations": [
      {
        "operationId": "listPets",
        "method": "GET",
        "path": "/pets",
        "summary": "List Pets",
        "returnType": "Pet[]"
      },
      {
        "operationId": "createPet",
        "method": "POST",
        "path": "/pets",
        "summary": "Create Pet",
        "returnType": "Pet"
      }
    ]
  },
  "renderedOutput": "// Auto-generated by OpenAPI Generator\nexport class PetStoreApiClient {\n  private baseUrl = 'https://api.petstore.example.com/v1';\n\n  async listPets(): Promise<Pet[]> {\n    const response = await fetch(`${this.baseUrl}/pets`);\n    return response.json();\n  }\n\n  async createPet(pet: Pet): Promise<Pet> {\n    const response = await fetch(`${this.baseUrl}/pets`, {\n      method: 'POST',\n      body: JSON.stringify(pet)\n    });\n    return response.json();\n  }\n}"
}