Project

Profile

Help

Issue #6372

Updated by daviddavis about 4 years ago

In our api schema generation code, we iterate through a sorted list of endpoints[0]. We build a list of resource examples as we go. We store them by a 'resource_path' (eg `/pulp/api/v3/repositories/file/file/{repository_pk}/'`)[1] but look them up 'resource_other_path' (eg `/pulp/api/v3/repositories/file/file/{pulp_id}/'`)[2]. 

 Consider the following sorted set of endpoints: 

 ``` 
 '/pulp/api/v3/repositories/file/file/{pulp_id}/' 
 '/pulp/api/v3/repositories/file/file/{repository_pk}/versions/' 
 '/pulp/api/v3/repositories/file/file/{repository_pk}/versions/{number}/' 
 ``` 

 When we get to the second endpoint, the resource_other_path is `'/pulp/api/v3/repositories/file/file/{pulp_id}/'` which exists in our resource_example because it was added when we processed `'/pulp/api/v3/repositories/file/file/{pulp_id}/'`.  

 But now consider a second set of endpoints: 

 ``` 
 '/pulp/api/v3/exporters/file/filesystem/{exporter_pk}/exports/', 
 '/pulp/api/v3/exporters/file/filesystem/{exporter_pk}/exports/{pulp_id}/', 
 '/pulp/api/v3/exporters/file/filesystem/{pulp_id}/', 
 ``` 

 When it goes to process the first item, it will try to lookup `'/pulp/api/v3/exporters/file/filesystem/{pulp_id}/'` which doesn't yet exist. 

 [0]    https://github.com/pulp/pulpcore/blob/4a63e05e9aa6f383c7ba756635c0d11c092d539c/pulpcore/app/openapigenerator.py#L72 
 [1] https://github.com/pulp/pulpcore/blob/master/pulpcore/app/openapigenerator.py#L119 
 [2] https://github.com/pulp/pulpcore/blob/master/pulpcore/app/openapigenerator.py#L121

Back