Skip to content

Commit

Permalink
alphanumeric component sorting.
Browse files Browse the repository at this point in the history
sry for the changing schema but it was inconsistent. this will not change anymore.
  • Loading branch information
tfranzel committed May 14, 2020
1 parent b7d673f commit 2bdd1ab
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 154 deletions.
4 changes: 2 additions & 2 deletions drf_spectacular/plumbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ def build(self, extra_components) -> dict:
output[extra_type][component_name] = component_schema
# sort by component type then by name
return {
type: {name: output[type][name] for name in output[type].keys()}
for type in sorted(output.keys(), reverse=True)
type: {name: output[type][name] for name in sorted(output[type].keys())}
for type in sorted(output.keys())
}


Expand Down
10 changes: 5 additions & 5 deletions tests/contrib/test_drf_jwt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ paths:
$ref: '#/components/schemas/X'
description: ''
components:
securitySchemes:
jwtAuth:
type: http
scheme: bearer
bearerFormat: Bearer
schemas:
JSONWebToken:
type: object
Expand All @@ -79,3 +74,8 @@ components:
format: uuid
required:
- uuid
securitySchemes:
jwtAuth:
type: http
scheme: bearer
bearerFormat: Bearer
24 changes: 12 additions & 12 deletions tests/contrib/test_oauth_toolkit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,19 @@ paths:
$ref: '#/components/schemas/X'
description: ''
components:
schemas:
X:
type: object
properties:
uuid:
type: string
format: uuid
required:
- uuid
securitySchemes:
basicAuth:
type: http
scheme: basic
oauth2:
type: oauth2
flows:
Expand All @@ -70,15 +82,3 @@ components:
read: Reading scope
write: Writing scope
extra_scope: Extra Scope
basicAuth:
type: http
scheme: basic
schemas:
X:
type: object
properties:
uuid:
type: string
format: uuid
required:
- uuid
52 changes: 26 additions & 26 deletions tests/contrib/test_rest_polymorphic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,7 @@ paths:
'204':
description: No response body
components:
securitySchemes:
cookieAuth:
type: apiKey
in: cookie
name: Session
basicAuth:
type: http
scheme: basic
schemas:
Person:
oneOf:
- $ref: '#/components/schemas/LegalPerson'
- $ref: '#/components/schemas/NaturalPerson'
discriminator:
propertyName: resourcetype
mapping:
legal: '#/components/schemas/LegalPerson'
natural: '#/components/schemas/NaturalPerson'
LegalPerson:
type: object
properties:
Expand Down Expand Up @@ -222,15 +205,6 @@ components:
- last_name
- address
- supervisor_id
PatchedPerson:
oneOf:
- $ref: '#/components/schemas/PatchedLegalPerson'
- $ref: '#/components/schemas/PatchedNaturalPerson'
discriminator:
propertyName: resourcetype
mapping:
legal: '#/components/schemas/PatchedLegalPerson'
natural: '#/components/schemas/PatchedNaturalPerson'
PatchedLegalPerson:
type: object
properties:
Expand Down Expand Up @@ -266,3 +240,29 @@ components:
supervisor_id:
type: integer
nullable: true
PatchedPerson:
oneOf:
- $ref: '#/components/schemas/PatchedLegalPerson'
- $ref: '#/components/schemas/PatchedNaturalPerson'
discriminator:
propertyName: resourcetype
mapping:
legal: '#/components/schemas/PatchedLegalPerson'
natural: '#/components/schemas/PatchedNaturalPerson'
Person:
oneOf:
- $ref: '#/components/schemas/LegalPerson'
- $ref: '#/components/schemas/NaturalPerson'
discriminator:
propertyName: resourcetype
mapping:
legal: '#/components/schemas/LegalPerson'
natural: '#/components/schemas/NaturalPerson'
securitySchemes:
basicAuth:
type: http
scheme: basic
cookieAuth:
type: apiKey
in: cookie
name: Session
10 changes: 5 additions & 5 deletions tests/contrib/test_simplejwt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ paths:
$ref: '#/components/schemas/X'
description: ''
components:
securitySchemes:
jwtAuth:
type: http
scheme: bearer
bearerFormat: Bearer
schemas:
TokenObtainPair:
type: object
Expand Down Expand Up @@ -110,3 +105,8 @@ components:
format: uuid
required:
- uuid
securitySchemes:
jwtAuth:
type: http
scheme: bearer
bearerFormat: Bearer
48 changes: 24 additions & 24 deletions tests/test_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ paths:
'200':
description: No response body
components:
securitySchemes:
tokenAuth:
type: http
scheme: bearer
bearerFormat: Token
schemas:
Album:
type: object
Expand Down Expand Up @@ -220,25 +215,6 @@ components:
- genre
- year
- released
Song:
type: object
properties:
id:
type: string
format: uuid
readOnly: true
title:
type: string
maxLength: 100
length:
type: integer
top10:
type: boolean
nullable: true
readOnly: true
required:
- title
- length
PatchedAlbum:
type: object
properties:
Expand All @@ -264,8 +240,32 @@ components:
type: integer
released:
type: boolean
Song:
type: object
properties:
id:
type: string
format: uuid
readOnly: true
title:
type: string
maxLength: 100
length:
type: integer
top10:
type: boolean
nullable: true
readOnly: true
required:
- title
- length
GenreEnum:
enum:
- POP
- ROCK
type: string
securitySchemes:
tokenAuth:
type: http
scheme: bearer
bearerFormat: Token
46 changes: 23 additions & 23 deletions tests/test_extend_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,6 @@ paths:
'201':
description: No response body
components:
securitySchemes:
cookieAuth:
type: apiKey
in: cookie
name: Session
basicAuth:
type: http
scheme: basic
schemas:
Alpha:
type: object
Expand All @@ -269,17 +261,13 @@ components:
- field_a
- field_b
- field_c
Gamma:
Delta:
type: object
properties:
encoding:
type: string
image_data:
field_a:
type: string
format: byte
required:
- encoding
- image_data
field_b:
type: integer
ErrorDetail:
type: object
properties:
Expand All @@ -300,6 +288,17 @@ components:
allOf:
- $ref: '#/components/schemas/FieldLEnum'
readOnly: true
Gamma:
type: object
properties:
encoding:
type: string
image_data:
type: string
format: byte
required:
- encoding
- image_data
Inline:
type: object
properties:
Expand All @@ -310,13 +309,6 @@ components:
required:
- inline_b
- inline_i
Delta:
type: object
properties:
field_a:
type: string
field_b:
type: integer
Query:
type: object
properties:
Expand Down Expand Up @@ -346,3 +338,11 @@ components:
- a
- b
type: string
securitySchemes:
basicAuth:
type: http
scheme: basic
cookieAuth:
type: apiKey
in: cookie
name: Session
16 changes: 8 additions & 8 deletions tests/test_fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ paths:
$ref: '#/components/schemas/AllFields'
description: ''
components:
securitySchemes:
cookieAuth:
type: apiKey
in: cookie
name: Session
basicAuth:
type: http
scheme: basic
schemas:
AllFields:
type: object
Expand Down Expand Up @@ -209,3 +201,11 @@ components:
- field_foreign
- field_o2o
- field_m2m
securitySchemes:
basicAuth:
type: http
scheme: basic
cookieAuth:
type: apiKey
in: cookie
name: Session
34 changes: 17 additions & 17 deletions tests/test_polymorphic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,7 @@ paths:
$ref: '#/components/schemas/MetaPerson'
description: ''
components:
securitySchemes:
cookieAuth:
type: apiKey
in: cookie
name: Session
basicAuth:
type: http
scheme: basic
schemas:
MetaPerson:
oneOf:
- $ref: '#/components/schemas/LegalPerson'
- $ref: '#/components/schemas/NaturalPerson'
discriminator:
propertyName: type
mapping:
legal: '#/components/schemas/LegalPerson'
natural: '#/components/schemas/NaturalPerson'
LegalPerson:
type: object
properties:
Expand All @@ -64,6 +47,15 @@ components:
readOnly: true
required:
- company_name
MetaPerson:
oneOf:
- $ref: '#/components/schemas/LegalPerson'
- $ref: '#/components/schemas/NaturalPerson'
discriminator:
propertyName: type
mapping:
legal: '#/components/schemas/LegalPerson'
natural: '#/components/schemas/NaturalPerson'
NaturalPerson:
type: object
properties:
Expand All @@ -82,3 +74,11 @@ components:
required:
- first_name
- last_name
securitySchemes:
basicAuth:
type: http
scheme: basic
cookieAuth:
type: apiKey
in: cookie
name: Session
Loading

0 comments on commit 2bdd1ab

Please sign in to comment.