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:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/user/{userId}/account_data/{type}":
|
"/user/{userId}/account_data/{type}":
|
||||||
put:
|
put:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/admin/whois/{userId}":
|
"/admin/whois/{userId}":
|
||||||
get:
|
get:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/account/password":
|
"/account/password":
|
||||||
post:
|
post:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/rooms/{roomId}/ban":
|
"/rooms/{roomId}/ban":
|
||||||
post:
|
post:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/createRoom":
|
"/createRoom":
|
||||||
post:
|
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:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/room/{roomAlias}":
|
"/room/{roomAlias}":
|
||||||
put:
|
put:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/rooms/{roomId}/context/{eventId}":
|
"/rooms/{roomId}/context/{eventId}":
|
||||||
get:
|
get:
|
||||||
|
|
|
@ -11,11 +11,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/user/{userId}/filter":
|
"/user/{userId}/filter":
|
||||||
post:
|
post:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
# With an extra " " to disambiguate from the 3pid invite endpoint
|
# 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.
|
# The extra space makes it sort first for what I'm sure is a good reason.
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/rooms/{roomId}/join":
|
"/rooms/{roomId}/join":
|
||||||
post:
|
post:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/rooms/{roomId}/kick":
|
"/rooms/{roomId}/kick":
|
||||||
post:
|
post:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/rooms/{roomId}/leave":
|
"/rooms/{roomId}/leave":
|
||||||
post:
|
post:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/login":
|
"/login":
|
||||||
post:
|
post:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/rooms/{roomId}/messages":
|
"/rooms/{roomId}/messages":
|
||||||
get:
|
get:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/events":
|
"/events":
|
||||||
get:
|
get:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/events":
|
"/events":
|
||||||
get:
|
get:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/presence/{userId}/status":
|
"/presence/{userId}/status":
|
||||||
put:
|
put:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/profile/{userId}/displayname":
|
"/profile/{userId}/displayname":
|
||||||
put:
|
put:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/pushers":
|
"/pushers":
|
||||||
get:
|
get:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/pushrules/":
|
"/pushrules/":
|
||||||
get:
|
get:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/rooms/{roomId}/receipt/{receiptType}/{eventId}":
|
"/rooms/{roomId}/receipt/{receiptType}/{eventId}":
|
||||||
post:
|
post:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/rooms/{roomId}/redact/{eventId}/{txnId}":
|
"/rooms/{roomId}/redact/{eventId}/{txnId}":
|
||||||
put:
|
put:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/rooms/{roomId}/send/{eventType}/{txnId}":
|
"/rooms/{roomId}/send/{eventType}/{txnId}":
|
||||||
put:
|
put:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/rooms/{roomId}/state/{eventType}/{stateKey}":
|
"/rooms/{roomId}/state/{eventType}/{stateKey}":
|
||||||
put:
|
put:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/rooms/{roomId}/state/{eventType}/{stateKey}":
|
"/rooms/{roomId}/state/{eventType}/{stateKey}":
|
||||||
get:
|
get:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/search":
|
"/search":
|
||||||
post:
|
post:
|
||||||
|
|
|
@ -11,11 +11,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/sync":
|
"/sync":
|
||||||
get:
|
get:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/user/{userId}/rooms/{roomId}/tags":
|
"/user/{userId}/rooms/{roomId}/tags":
|
||||||
get:
|
get:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/rooms/{roomId}/invite":
|
"/rooms/{roomId}/invite":
|
||||||
post:
|
post:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/rooms/{roomId}/typing/{userId}":
|
"/rooms/{roomId}/typing/{userId}":
|
||||||
put:
|
put:
|
||||||
|
|
|
@ -12,11 +12,7 @@ consumes:
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
accessToken:
|
$ref: definitions/security.yaml
|
||||||
type: apiKey
|
|
||||||
description: The user_id or application service access_token
|
|
||||||
name: access_token
|
|
||||||
in: query
|
|
||||||
paths:
|
paths:
|
||||||
"/voip/turnServer":
|
"/voip/turnServer":
|
||||||
get:
|
get:
|
||||||
|
|
|
@ -12,9 +12,12 @@ import os.path
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
import yaml
|
||||||
|
|
||||||
scripts_dir = os.path.dirname(os.path.abspath(__file__))
|
scripts_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
templating_dir = os.path.join(os.path.dirname(scripts_dir), "templating")
|
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)
|
sys.path.insert(0, templating_dir)
|
||||||
|
|
||||||
from matrix_templates.units import resolve_references, MatrixUnits
|
from matrix_templates.units import resolve_references, MatrixUnits
|
||||||
|
@ -50,10 +53,15 @@ output = {
|
||||||
"title": "Matrix Client-Server API",
|
"title": "Matrix Client-Server API",
|
||||||
"version": release_label,
|
"version": release_label,
|
||||||
},
|
},
|
||||||
|
"securityDefinitions": {},
|
||||||
"paths": {},
|
"paths": {},
|
||||||
"swagger": "2.0",
|
"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 file, contents in apis.items():
|
||||||
for path, methods in contents["paths"].items():
|
for path, methods in contents["paths"].items():
|
||||||
for method, spec in methods.items():
|
for method, spec in methods.items():
|
||||||
|
@ -62,6 +70,8 @@ for file, contents in apis.items():
|
||||||
output["paths"][path] = {}
|
output["paths"][path] = {}
|
||||||
output["paths"][path][method] = spec
|
output["paths"][path][method] = spec
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print "Generating %s" % output_file
|
print "Generating %s" % output_file
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue