File tree Expand file tree Collapse file tree 5 files changed +138
-10
lines changed
Expand file tree Collapse file tree 5 files changed +138
-10
lines changed Original file line number Diff line number Diff line change 1818from django .conf .urls .static import static
1919from django .contrib import admin
2020from django .urls import include , path , re_path
21+ from drf_spectacular .views import SpectacularAPIView , SpectacularSwaggerView
2122from mitol .apigateway .views import ApiGatewayLogoutView
2223from oauth2_provider .urls import base_urlpatterns , oidc_urlpatterns
2324from wagtail import urls as wagtail_urls
3940 path ("admin/" , admin .site .urls ),
4041 path ("hijack/" , include ("hijack.urls" )),
4142 path ("robots.txt" , include ("robots.urls" )),
43+ re_path (r"^api/schema/$" , SpectacularAPIView .as_view (), name = "schema" ),
44+ re_path (
45+ r"^api/schema/swagger-ui/$" ,
46+ SpectacularSwaggerView .as_view (url_name = "schema" ),
47+ name = "swagger" ,
48+ ),
4249 path ("" , include ("authentication.urls" )),
4350 path ("" , include ("authentication.new_urls" )),
4451 path ("" , include ("openedx.urls" )),
Original file line number Diff line number Diff line change @@ -2385,9 +2385,7 @@ components:
23852385 b2b_organizations :
23862386 type : array
23872387 items :
2388- type : object
2389- additionalProperties : {}
2390- description : Get the organizations for the user
2388+ $ref : ' #/components/schemas/UserOrganization'
23912389 readOnly : true
23922390 required :
23932391 - b2b_organizations
@@ -2401,6 +2399,48 @@ components:
24012399 - is_superuser
24022400 - legal_address
24032401 - updated_on
2402+ UserOrganization :
2403+ type : object
2404+ description : |-
2405+ Serializer for user organization data.
2406+
2407+ Slightly different from the OrganizationPageSerializer; we only need
2408+ the user's orgs and contracts.
2409+ properties :
2410+ id :
2411+ type : integer
2412+ readOnly : true
2413+ name :
2414+ type : string
2415+ readOnly : true
2416+ description : The name of the organization
2417+ description :
2418+ type : string
2419+ readOnly : true
2420+ description : Any useful extra information about the organization
2421+ logo :
2422+ type : string
2423+ format : uri
2424+ readOnly : true
2425+ description : The organization's logo. Will be displayed in the app in various
2426+ places.
2427+ slug :
2428+ type : string
2429+ readOnly : true
2430+ description : The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/
2431+ pattern : ^[-\w]+$
2432+ contracts :
2433+ type : array
2434+ items :
2435+ $ref : ' #/components/schemas/ContractPage'
2436+ readOnly : true
2437+ required :
2438+ - contracts
2439+ - description
2440+ - id
2441+ - logo
2442+ - name
2443+ - slug
24042444 UserProfile :
24052445 type : object
24062446 description : Serializer for profile
Original file line number Diff line number Diff line change @@ -2385,9 +2385,7 @@ components:
23852385 b2b_organizations :
23862386 type : array
23872387 items :
2388- type : object
2389- additionalProperties : {}
2390- description : Get the organizations for the user
2388+ $ref : ' #/components/schemas/UserOrganization'
23912389 readOnly : true
23922390 required :
23932391 - b2b_organizations
@@ -2401,6 +2399,48 @@ components:
24012399 - is_superuser
24022400 - legal_address
24032401 - updated_on
2402+ UserOrganization :
2403+ type : object
2404+ description : |-
2405+ Serializer for user organization data.
2406+
2407+ Slightly different from the OrganizationPageSerializer; we only need
2408+ the user's orgs and contracts.
2409+ properties :
2410+ id :
2411+ type : integer
2412+ readOnly : true
2413+ name :
2414+ type : string
2415+ readOnly : true
2416+ description : The name of the organization
2417+ description :
2418+ type : string
2419+ readOnly : true
2420+ description : Any useful extra information about the organization
2421+ logo :
2422+ type : string
2423+ format : uri
2424+ readOnly : true
2425+ description : The organization's logo. Will be displayed in the app in various
2426+ places.
2427+ slug :
2428+ type : string
2429+ readOnly : true
2430+ description : The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/
2431+ pattern : ^[-\w]+$
2432+ contracts :
2433+ type : array
2434+ items :
2435+ $ref : ' #/components/schemas/ContractPage'
2436+ readOnly : true
2437+ required :
2438+ - contracts
2439+ - description
2440+ - id
2441+ - logo
2442+ - name
2443+ - slug
24042444 UserProfile :
24052445 type : object
24062446 description : Serializer for profile
Original file line number Diff line number Diff line change @@ -2385,9 +2385,7 @@ components:
23852385 b2b_organizations :
23862386 type : array
23872387 items :
2388- type : object
2389- additionalProperties : {}
2390- description : Get the organizations for the user
2388+ $ref : ' #/components/schemas/UserOrganization'
23912389 readOnly : true
23922390 required :
23932391 - b2b_organizations
@@ -2401,6 +2399,48 @@ components:
24012399 - is_superuser
24022400 - legal_address
24032401 - updated_on
2402+ UserOrganization :
2403+ type : object
2404+ description : |-
2405+ Serializer for user organization data.
2406+
2407+ Slightly different from the OrganizationPageSerializer; we only need
2408+ the user's orgs and contracts.
2409+ properties :
2410+ id :
2411+ type : integer
2412+ readOnly : true
2413+ name :
2414+ type : string
2415+ readOnly : true
2416+ description : The name of the organization
2417+ description :
2418+ type : string
2419+ readOnly : true
2420+ description : Any useful extra information about the organization
2421+ logo :
2422+ type : string
2423+ format : uri
2424+ readOnly : true
2425+ description : The organization's logo. Will be displayed in the app in various
2426+ places.
2427+ slug :
2428+ type : string
2429+ readOnly : true
2430+ description : The name of the page as it will appear in URLs e.g http://domain.com/blog/[my-slug]/
2431+ pattern : ^[-\w]+$
2432+ contracts :
2433+ type : array
2434+ items :
2435+ $ref : ' #/components/schemas/ContractPage'
2436+ readOnly : true
2437+ required :
2438+ - contracts
2439+ - description
2440+ - id
2441+ - logo
2442+ - name
2443+ - slug
24042444 UserProfile :
24052445 type : object
24062446 description : Serializer for profile
Original file line number Diff line number Diff line change @@ -192,6 +192,7 @@ class UserOrganizationSerializer(OrganizationPageSerializer):
192192
193193 contracts = serializers .SerializerMethodField ()
194194
195+ @extend_schema_field (ContractPageSerializer (many = True ))
195196 def get_contracts (self , instance ):
196197 """Get the contracts for the organization for the user"""
197198 contracts = (
@@ -264,7 +265,7 @@ def get_username(self, instance):
264265 def get_grants (self , instance ):
265266 return instance .get_all_permissions ()
266267
267- @extend_schema_field (list [ dict ] )
268+ @extend_schema_field (UserOrganizationSerializer ( many = True ) )
268269 def get_b2b_organizations (self , instance ):
269270 """Get the organizations for the user"""
270271 if instance .is_anonymous :
You can’t perform that action at this time.
0 commit comments