Project

Profile

Help

Issue #6372

closed

KeyError when generating api schema with nested routes

Added by daviddavis over 4 years ago. Updated over 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Category:
-
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
No
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Sprint 69
Quarter:

Description

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

Actions #1

Updated by daviddavis over 4 years ago

  • Description updated (diff)
Actions #2

Updated by dkliban@redhat.com over 4 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to dkliban@redhat.com
  • Sprint set to Sprint 69
Actions #3

Updated by dkliban@redhat.com over 4 years ago

  • Status changed from ASSIGNED to POST

Added by dkliban@redhat.com over 4 years ago

Revision 3a62068d | View on GitHub

Normalize PK path parameter names used in openapi schema generation

This ensures that when the endpoints are sorted, the parent endpoint appears before the endpoints nested under it.

fixes: #6372 https://pulp.plan.io/issues/6372

Actions #4

Updated by dkliban@redhat.com over 4 years ago

  • Status changed from POST to MODIFIED
Actions #5

Updated by ttereshc over 4 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE
  • Sprint/Milestone set to 3.3.0

Also available in: Atom PDF