Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating an Open Api specification #53

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions openapi-codegen-php.json
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinks you 10060213

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"composerVendorName": "xtrime-ru",
"composerProjectName": "TelegramPhpClient",
"artifactVersion": "1.10.4",
"invokerPackage": "xtrime-ru\\TelegramPhpClient",
"packagePath": "TelegramPhpClient"
}
93 changes: 93 additions & 0 deletions openapi-codegen-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
## Download swagger-codegen binary

```bash
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.22/swagger-codegen-cli-3.0.22.jar -O swagger-codegen-cli.jar
```


## Generate single open api yaml file

```bash
docker run --rm -v ${PWD}:/local -w /local openjdk java -jar swagger-codegen-cli.jar generate \
--input-spec /local/openapi.yaml --lang openapi-yaml --output /local/out/ -c /local/openapi-codegen-php.json
```

## Generate PHP client library

```bash
docker run --rm -v ${PWD}:/local -w /local openjdk java -jar swagger-codegen-cli.jar generate \
--input-spec /local/openapi.yaml --lang php --output /local/out/ -c /local/openapi-codegen-php.json
```

### Use custom codegenerator templates

`--template-dir /local/php/`

## Generate other

docker run --rm -v ${PWD}:/local -w /local openjdk java -jar swagger-codegen-cli.jar generate \
--input-spec /local/openapi.yaml --lang dynamic-html --output /local/out/ -c /local/openapi-codegen-php.json

docker run --rm -v ${PWD}:/local -w /local openjdk java -jar swagger-codegen-cli.jar generate \
--input-spec /local/openapi.yaml --lang html --output /local/out/ -c /local/openapi-codegen-php.json




docker run --rm \
-v $PWD:/local \
openapitools/openapi-generator-cli \
generate \
-i /local/openapi.yaml \
-g asciidoc \
-o /local/out/asciidoc


docker run --rm \
-v $PWD:/local \
openapitools/openapi-generator-cli \
generate \
-i /local/openapi.yaml \
-g dynamic-html \
-o /local/out/dynamic-html


docker run --rm \
-v $PWD:/local \
openapitools/openapi-generator-cli \
generate \
-i /local/openapi.yaml \
-g html2 \
-o /local/out/html2


docker run --rm \
-v $PWD:/local \
openapitools/openapi-generator-cli \
generate \
-i /local/openapi.yaml \
-g openapi \
-o /local/out/openapi


docker run --rm \
-v $PWD:/local \
openapitools/openapi-generator-cli \
generate \
-i /local/openapi.yaml \
-g openapi-yaml \
-o /local/out/openapi-yaml


docker run --rm \
--network host \
-v $PWD:/local \
openapitools/openapi-generator-cli \
generate \
-i https://docs.api2.dev.hoqu.com/docs/api.yml \
-g openapi-yaml \
-o /local/out/hoq0-openapi-yaml


Swagger-Codegen/1.10.4/php

63 changes: 63 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
openapi: 3.0.1

info:
title: Telegram Api Server
description: 'Fast, simple, async php telegram api server: MadelineProto + Amp HTTP
Server'
license:
name: MIT License
url: https://github.com/xtrime-ru/TelegramApiServer/blob/master/LICENSE
version: 1.10.4

externalDocs:
description: Async PHP client/server API for the telegram MTProto protocol
url: https://github.com/danog/MadelineProto

servers:
- url: https://example.com/
- url: http://example.com/

#security:
#- basicAuth: []

tags:
- name: system
description: Different settings for sessions
externalDocs:
description: Find out more
url: https://github.com/xtrime-ru/TelegramApiServer#different-settings-for-sessions

- name: api
description: All methods from MadelineProto supported
externalDocs:
description: Methods List
url: https://docs.madelineproto.xyz/API_docs/methods/

- name: login
description: Login methods from MadelineProto
externalDocs:
description: Methods List
url: https://docs.madelineproto.xyz/API_docs/methods/

paths:
/system/getSessionList:
$ref: './openapi/paths/system/getSessionList.yaml'

/system/addSession:
$ref: './openapi/paths/system/addSession.yaml'

/api/{session}/phoneLogin:
$ref: './openapi/paths/api/phoneLogin.yaml'

/api/{session}/completePhoneLogin:
$ref: './openapi/paths/api/completePhoneLogin.yaml'

/api/{session}/completeSignup:
$ref: './openapi/paths/api/completeSignup.yaml'



# securitySchemes:
# basicAuth:
# type: http
# scheme: basic
7 changes: 7 additions & 0 deletions openapi/models/api/AccountNeedSignup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: object
properties:
_:
type: string
default: "account.needSignup"
terms_of_service:
$ref: '../api/TermsOfService.yaml'
7 changes: 7 additions & 0 deletions openapi/models/api/AuthAuthorization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: object
properties:
_:
type: string
default: "auth.authorization"
user:
$ref: '../api/User.yaml'
18 changes: 18 additions & 0 deletions openapi/models/api/AuthSentCode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
type: object
properties:
_:
type: string
default: "auth.sentCode"
type:
$ref: '../api/SentCodeTypeSms.yaml'
phone_code_hash:
type: string
example: "3aae168ea0609da27f"
next_type:
$ref: '../api/CodeTypeCall.yaml'
timeout:
type: integer
example: 120
phone_number:
type: string
example: "+79636025112"
4 changes: 4 additions & 0 deletions openapi/models/api/CodeTypeCall.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
properties:
_:
type: string
default: "auth.codeTypeCall"
7 changes: 7 additions & 0 deletions openapi/models/api/SentCodeTypeSms.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
properties:
_:
type: string
default: "auth.sentCodeTypeSms"
length:
type: integer
example: 5
16 changes: 16 additions & 0 deletions openapi/models/api/TermsOfService.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type: object
properties:
_:
type: string
default: "help.termsOfService"
popup:
type: boolean
default: false
id:
$ref: '../api/TermsOfServiceId.yaml'
text:
type: string
default: "By signing up for Telegram, you agree not to:\n\n- Use our service to send spam or scam users.\n- Promote violence on publicly viewable Telegram bots, groups or channels.\n- Post pornographic content on publicly viewable Telegram bots, groups or channels.\n\nWe reserve the right to update these Terms of Service later."
entities:
type: array
items: {}
19 changes: 19 additions & 0 deletions openapi/models/api/TermsOfServiceId.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
properties:
country:
type: string
example: "RU"
min_age:
type: boolean
default: false
terms_key:
type: string
example: "TERMS_OF_SERVICE"
terms_lang:
type: string
example: "en"
terms_version:
type: integer
default: 1
terms_hash:
type: string
default: "7dca806cb8d387c07c778ce9ef6aac04"
40 changes: 40 additions & 0 deletions openapi/models/api/User.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
properties:
_:
type: string
default: "user"
self:
type: boolean
contact:
type: boolean
mutual_contact:
type: boolean
deleted:
type: boolean
bot:
type: boolean
bot_chat_history:
type: boolean
bot_nochats:
type: boolean
verified:
type: boolean
restricted:
type: boolean
min:
type: boolean
bot_inline_geo:
type: boolean
support:
type: boolean
scam:
type: boolean
id:
type: integer
access_hash:
type: integer
example: 4963221948965825237
first_name:
type: string
phone:
type: string
example: "79636025112"
15 changes: 15 additions & 0 deletions openapi/models/common/Backtrace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
type: object
properties:
file:
type: string
line:
type: integer
function:
type: string
class:
type: string
type:
type: string
args:
type: array
items: {}
3 changes: 3 additions & 0 deletions openapi/models/common/BacktraceArray.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type: array
items:
$ref: '../models/Backtrace.yaml'
16 changes: 16 additions & 0 deletions openapi/models/common/Error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type: object
properties:
exception:
type: string
message:
type: string
file:
type: string
line:
type: integer
code:
type: integer
backtrace:
type: array
items:
$ref: '../common/Backtrace.yaml'
7 changes: 7 additions & 0 deletions openapi/models/system/AppInfo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
properties:
app_id:
type: integer
description: App api_id
app_hash:
type: string
description: App api_hash
14 changes: 14 additions & 0 deletions openapi/models/system/Session.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
properties:
session:
type: string
file:
type: string
status:
type: string
enum:
- NOT_LOGGED_IN
- WAITING_CODE
- WAITING_PASSWORD
- WAITING_SIGNUP
- LOGGED_IN
- LOADING
7 changes: 7 additions & 0 deletions openapi/models/system/SessionList.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
properties:
sessions:
type: object
additionalProperties:
$ref: '../system/Session.yaml'
memory:
type: string
4 changes: 4 additions & 0 deletions openapi/models/system/SessionSettings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type: object
properties:
app_info:
$ref: '../system/AppInfo.yaml'
6 changes: 6 additions & 0 deletions openapi/parameters/session.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
in: path
name: session
schema:
type: string
required: true
description: Session name
Loading