mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00
openapi: better handle nested schemas
there is a 2 levels schemas in profile.notifications. The code previously assumed we could only have one level, and so was not producing the correct UsersProfileNotifications. Fix that by being more generic in the way we retrieve the nested subschemas.
This commit is contained in:
parent
8ec1e4f3fa
commit
ae30b1220a
2 changed files with 37 additions and 27 deletions
|
@ -607,6 +607,9 @@ class SchemaProperty(object):
|
||||||
|
|
||||||
# deal with subschemas
|
# deal with subschemas
|
||||||
if '.' in name:
|
if '.' in name:
|
||||||
|
subschema = name.split('.')[0]
|
||||||
|
subschema = subschema.capitalize()
|
||||||
|
|
||||||
if name.endswith('$'):
|
if name.endswith('$'):
|
||||||
# reference in reference
|
# reference in reference
|
||||||
subschema = ''.join([n.capitalize() for n in self.name.split('.')[:-1]])
|
subschema = ''.join([n.capitalize() for n in self.name.split('.')[:-1]])
|
||||||
|
@ -621,9 +624,12 @@ class SchemaProperty(object):
|
||||||
print(''' {}:
|
print(''' {}:
|
||||||
type: object'''.format(subschema))
|
type: object'''.format(subschema))
|
||||||
return current_schema
|
return current_schema
|
||||||
|
elif '$' in name:
|
||||||
|
# In the form of 'profile.notifications.$.activity'
|
||||||
|
subschema = name[:name.index('$') - 1] # 'profile.notifications'
|
||||||
|
subschema = ''.join([s.capitalize() for s in subschema.split('.')])
|
||||||
|
|
||||||
subschema = name.split('.')[0]
|
schema_name = self.schema.name + subschema
|
||||||
schema_name = self.schema.name + subschema.capitalize()
|
|
||||||
name = name.split('.')[-1]
|
name = name.split('.')[-1]
|
||||||
|
|
||||||
if current_schema != schema_name:
|
if current_schema != schema_name:
|
||||||
|
@ -755,7 +761,7 @@ class Schemas(object):
|
||||||
# then print the references
|
# then print the references
|
||||||
current = None
|
current = None
|
||||||
required_properties = []
|
required_properties = []
|
||||||
properties = [f for f in self.fields if '.' in f.name and not f.name.endswith('$')]
|
properties = [f for f in self.fields if '.' in f.name and not '$' in f.name]
|
||||||
for prop in properties:
|
for prop in properties:
|
||||||
current = prop.print_openapi(6, current, required_properties)
|
current = prop.print_openapi(6, current, required_properties)
|
||||||
|
|
||||||
|
@ -766,7 +772,7 @@ class Schemas(object):
|
||||||
|
|
||||||
required_properties = []
|
required_properties = []
|
||||||
# then print the references in the references
|
# then print the references in the references
|
||||||
for prop in [f for f in self.fields if '.' in f.name and f.name.endswith('$')]:
|
for prop in [f for f in self.fields if '.' in f.name and '$' in f.name]:
|
||||||
current = prop.print_openapi(6, current, required_properties)
|
current = prop.print_openapi(6, current, required_properties)
|
||||||
|
|
||||||
if required_properties:
|
if required_properties:
|
||||||
|
|
|
@ -3681,20 +3681,6 @@ definitions:
|
||||||
- createdAt
|
- createdAt
|
||||||
- modifiedAt
|
- modifiedAt
|
||||||
- authenticationMethod
|
- authenticationMethod
|
||||||
UsersEmails:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
address:
|
|
||||||
description: |
|
|
||||||
The email address
|
|
||||||
type: string
|
|
||||||
verified:
|
|
||||||
description: |
|
|
||||||
Has the email been verified
|
|
||||||
type: boolean
|
|
||||||
required:
|
|
||||||
- address
|
|
||||||
- verified
|
|
||||||
UsersProfile:
|
UsersProfile:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -3750,14 +3736,6 @@ definitions:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/definitions/UsersProfileNotifications"
|
$ref: "#/definitions/UsersProfileNotifications"
|
||||||
activity:
|
|
||||||
description: |
|
|
||||||
The id of the activity this notification references
|
|
||||||
type: string
|
|
||||||
read:
|
|
||||||
description: |
|
|
||||||
the date on which this notification was read
|
|
||||||
type: string
|
|
||||||
showCardsCountAt:
|
showCardsCountAt:
|
||||||
description: |
|
description: |
|
||||||
showCardCountAt field of the user
|
showCardCountAt field of the user
|
||||||
|
@ -3813,7 +3791,6 @@ definitions:
|
||||||
Reference to the board templates swimlane Id
|
Reference to the board templates swimlane Id
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
- activity
|
|
||||||
- templatesBoardId
|
- templatesBoardId
|
||||||
- cardTemplatesSwimlaneId
|
- cardTemplatesSwimlaneId
|
||||||
- listTemplatesSwimlaneId
|
- listTemplatesSwimlaneId
|
||||||
|
@ -3829,3 +3806,30 @@ definitions:
|
||||||
description: |
|
description: |
|
||||||
last hit that was returned
|
last hit that was returned
|
||||||
type: number
|
type: number
|
||||||
|
UsersEmails:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
address:
|
||||||
|
description: |
|
||||||
|
The email address
|
||||||
|
type: string
|
||||||
|
verified:
|
||||||
|
description: |
|
||||||
|
Has the email been verified
|
||||||
|
type: boolean
|
||||||
|
required:
|
||||||
|
- address
|
||||||
|
- verified
|
||||||
|
UsersProfileNotifications:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
activity:
|
||||||
|
description: |
|
||||||
|
The id of the activity this notification references
|
||||||
|
type: string
|
||||||
|
read:
|
||||||
|
description: |
|
||||||
|
the date on which this notification was read
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- activity
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue