Add securityDefintions to generated swagger JSON
Also factor out to a common file
This commit is contained in:
parent
cf87120d78
commit
23c4ffbc1b
33 changed files with 46 additions and 155 deletions
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/user/{userId}/account_data/{type}":
|
||||
put:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/admin/whois/{userId}":
|
||||
get:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/account/password":
|
||||
post:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/rooms/{roomId}/ban":
|
||||
post:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/createRoom":
|
||||
post:
|
||||
|
|
5
api/client-server/definitions/security.yaml
Normal file
5
api/client-server/definitions/security.yaml
Normal file
|
@ -0,0 +1,5 @@
|
|||
accessToken:
|
||||
type: apiKey
|
||||
description: The access_token returned by a call to ``/login`` or ``/tokenrefresh``
|
||||
name: access_token
|
||||
in: query
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/room/{roomAlias}":
|
||||
put:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/rooms/{roomId}/context/{eventId}":
|
||||
get:
|
||||
|
|
|
@ -11,11 +11,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/user/{userId}/filter":
|
||||
post:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
# With an extra " " to disambiguate from the 3pid invite endpoint
|
||||
# The extra space makes it sort first for what I'm sure is a good reason.
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/rooms/{roomId}/join":
|
||||
post:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/rooms/{roomId}/kick":
|
||||
post:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/rooms/{roomId}/leave":
|
||||
post:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/login":
|
||||
post:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/rooms/{roomId}/messages":
|
||||
get:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/events":
|
||||
get:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/events":
|
||||
get:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/presence/{userId}/status":
|
||||
put:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/profile/{userId}/displayname":
|
||||
put:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/pushers":
|
||||
get:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/pushrules/":
|
||||
get:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/rooms/{roomId}/receipt/{receiptType}/{eventId}":
|
||||
post:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/rooms/{roomId}/redact/{eventId}/{txnId}":
|
||||
put:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/rooms/{roomId}/send/{eventType}/{txnId}":
|
||||
put:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/rooms/{roomId}/state/{eventType}/{stateKey}":
|
||||
put:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/rooms/{roomId}/state/{eventType}/{stateKey}":
|
||||
get:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/search":
|
||||
post:
|
||||
|
|
|
@ -11,11 +11,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/sync":
|
||||
get:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/user/{userId}/rooms/{roomId}/tags":
|
||||
get:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/rooms/{roomId}/invite":
|
||||
post:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/rooms/{roomId}/typing/{userId}":
|
||||
put:
|
||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
|||
produces:
|
||||
- application/json
|
||||
securityDefinitions:
|
||||
accessToken:
|
||||
type: apiKey
|
||||
description: The user_id or application service access_token
|
||||
name: access_token
|
||||
in: query
|
||||
$ref: definitions/security.yaml
|
||||
paths:
|
||||
"/voip/turnServer":
|
||||
get:
|
||||
|
|
|
@ -12,9 +12,12 @@ import os.path
|
|||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
scripts_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
templating_dir = os.path.join(os.path.dirname(scripts_dir), "templating")
|
||||
api_dir = os.path.join(os.path.dirname(scripts_dir), "api")
|
||||
|
||||
sys.path.insert(0, templating_dir)
|
||||
|
||||
from matrix_templates.units import resolve_references, MatrixUnits
|
||||
|
@ -50,10 +53,15 @@ output = {
|
|||
"title": "Matrix Client-Server API",
|
||||
"version": release_label,
|
||||
},
|
||||
"securityDefinitions": {},
|
||||
"paths": {},
|
||||
"swagger": "2.0",
|
||||
}
|
||||
|
||||
with open(os.path.join(api_dir, 'client-server', 'definitions',
|
||||
'security.yaml')) as f:
|
||||
output['securityDefinitions'] = yaml.load(f)
|
||||
|
||||
for file, contents in apis.items():
|
||||
for path, methods in contents["paths"].items():
|
||||
for method, spec in methods.items():
|
||||
|
@ -62,6 +70,8 @@ for file, contents in apis.items():
|
|||
output["paths"][path] = {}
|
||||
output["paths"][path][method] = spec
|
||||
|
||||
|
||||
|
||||
print "Generating %s" % output_file
|
||||
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue