openapi: 3.0.0 info: title: "{{ .Title }}" version: "{{ .Version }}" description: |- This OpenAPI specification was generated using the [tgbotspec](https://github.com/metalagman/tgbotspec) tool. servers: - url: "https://api.telegram.org/bot{botToken}" description: Telegram Bot API endpoint; substitute {botToken} with your bot token. variables: botToken: description: Telegram bot token obtained from BotFather. default: "" security: - TelegramBotToken: [] paths: {{- range .Methods}} /{{ .Name }}: post: operationId: {{ .Name }} {{- if .Tags }} tags: {{- range .Tags}} - {{ . }} {{- end}} {{- end}} description: |- {{- range .Description}} {{ . }} {{- end}} {{- if .Params }} requestBody: required: true content: application/json: schema: type: object properties: {{- range .Params}} {{- if not (isPureBinary .Schema) }} {{ .Name }}: {{ indent 18 (renderJSONSchema .Schema) }} {{- end}} {{- end}} {{- $req := false }} {{- range .Params}} {{- if and .Required (not (isPureBinary .Schema)) }}{{ $req = true }}{{- end}} {{- end}} {{- if $req}} required: {{- range .Params}} {{- if and .Required (not (isPureBinary .Schema)) }} - {{ .Name }} {{- end}} {{- end}} {{- end}} {{- if .SupportsMultipart }} multipart/form-data: schema: type: object properties: {{- range .Params}} {{ .Name }}: {{ indent 18 (renderMultipartSchema .Schema .JSONEncoded) }} {{- end}} {{- $req := false }} {{- range .Params}} {{- if .Required }}{{ $req = true }}{{- end}} {{- end}} {{- if $req}} required: {{- range .Params}} {{- if .Required}} - {{ .Name }} {{- end}} {{- end}} {{- end}} {{- end}} {{- end}} responses: '200': description: OK content: application/json: schema: {{- if .Return }} allOf: - $ref: '#/components/schemas/OkResponse' - type: object properties: result: {{ indent 24 (renderSchema .Return) }} required: - result {{- else }} $ref: '#/components/schemas/OkResponse' {{- end }} '400': description: Bad Request content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' {{- end}} components: securitySchemes: TelegramBotToken: type: http scheme: bearer bearerFormat: TelegramBotToken description: Telegram bot token included in the request URL segment (bot{token}). schemas: {{- range .Types}} {{.Name}}: {{- if eq .Name "True"}} type: boolean enum: - true description: |- {{- range .Description}} {{ . }} {{- end}} {{- if .Tag}} x-tags: - {{ .Tag }} {{- end}} {{- else}} type: object description: |- {{- range .Description}} {{ . }} {{- end}} {{- if .Tag}} x-tags: - {{ .Tag }} {{- end}} {{- if .Fields}} properties: {{- range .Fields}} {{ .Name }}: {{ indent 10 (renderSchema .Schema) }} {{- end}} {{- end}} {{- $req := false }} {{- range .Fields}} {{- if .Required }}{{ $req = true }}{{- end}} {{- end}} {{- if $req}} required: {{- range .Fields}} {{- if .Required}} - {{ .Name }} {{- end}} {{- end}} {{- end}} {{- end}} {{- end}} OkResponse: type: object properties: ok: type: boolean enum: - true required: - ok ErrorResponse: type: object properties: ok: type: boolean enum: - false error_code: type: integer description: type: string parameters: $ref: '#/components/schemas/ResponseParameters' required: - ok - error_code - description