const template = ` import {HeroPattern} from "@/components/HeroPattern"; import {Note} from "@/components/mdx"; <% operations.forEach(function(operation){ %> ## <%- operation.summary %> {{ tag: '<%- operation.operation.toUpperCase() %>' , label: '<%- operation.path %>' }} <%- operation.description %> <% if(operation.parameters && operation.parameters.filter((parameter) => parameter.in === 'path').length > 0){ %> #### Path Parameters <% operation.parameters.filter((parameter) => parameter.in === 'path').forEach(function(parameter){ %> <%- parameter.description %> <% }); -%> <% }; -%> <% if(operation.parameters && operation.parameters.filter((parameter) => parameter.in === 'query').length > 0){ %> #### Query Parameters <% operation.parameters.filter((parameter) => parameter.in === 'query').forEach(function(parameter){ %> <%- parameter.description %> <% }); -%> <% }; -%> <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ %> #### Request-Body Parameters <% schemas.get(operation.requestBody?.content['application/json'].schema.$ref.split('/').pop())?.parameters.forEach(function(parameter){ %> \} <% if(parameter.enum){ %> enumList="<%- parameter.enum %>" <% }; -%> <% if(parameter.minimum){ %> min=\{<%- parameter.minimum %>\} <% }; -%> <% if(parameter.maximum){ %> max=\{<%- parameter.maximum %>\} <% }; -%> <% if(parameter.minLength){ %> minLen=\{<%- parameter.minLength %>\} <% }; -%> <% if(parameter.maxLength){ %> maxLen=\{<%- parameter.maxLength %>\} <% }; -%> > <%- parameter.description %> <% }); -%> <% }; -%> \`\`\`bash {{ title: 'cURL' }} curl -X <%- operation.operation.toUpperCase() %> <%- operation.fullPath %> \\ -H "Authorization: Bearer {token}" \\ <% if(operation.responseList[0].content && operation.responseList[0].content['application/json']){ -%> -H 'Accept: application/json' \\<% }; %> <% if(operation.requestBody?.content && operation.requestBody?.content['application/json']){ -%> -H 'Content-Type: application/json' \\ --data-raw '<%- JSON.stringify(schemas.get(operation.requestBody?.content['application/json'].schema.$ref?.split('/').pop())?.examples, null, 2) %>'<% }; %> \`\`\` \`\`\`js import ApiClient from '@example/protocol-api' const client = new ApiClient(token) await client.contacts.update('WAz8eIbvDR60rouK', { display_name: 'UncleFrank', }) \`\`\` \`\`\`python from protocol_api import ApiClient client = ApiClient(token) client.contacts.update("WAz8eIbvDR60rouK", display_name="UncleFrank") \`\`\` \`\`\`php $client = new \\Protocol\\ApiClient($token); $client->contacts->update('WAz8eIbvDR60rouK', [ 'display_name' => 'UncleFrank', ]); \`\`\` <% operation.responseList.forEach(function(response){ %> <% if(response?.content && response?.content['application/json']){ %> <% if(response?.content['application/json'].schema.type === 'array'){ %> \`\`\`json {{ title: '200' }} <%- JSON.stringify(new Array(schemas.get(response?.content['application/json'].schema.items.$ref?.split('/').pop())?.examples), null, 2) %> \`\`\` <% } else { %> \`\`\`json {{ title: '200' }} <%- JSON.stringify(schemas.get(response?.content['application/json'].schema.$ref?.split('/').pop())?.examples, null, 2) %> \`\`\` <% }; -%> <% }; -%> <% }); -%> --- <% }); -%> `.trim() export default template