Project

Profile

Help

Issue #6372

KeyError when generating api schema with nested routes

Added by daviddavis 5 months ago. Updated 4 months 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

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

Associated revisions

Revision 3a62068d View on GitHub
Added by dkliban@redhat.com 5 months ago

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

History

#1 Updated by daviddavis 5 months ago

  • Description updated (diff)

#2 Updated by dkliban@redhat.com 5 months ago

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

#3 Updated by dkliban@redhat.com 5 months ago

  • Status changed from ASSIGNED to POST

#4 Updated by dkliban@redhat.com 5 months ago

  • Status changed from POST to MODIFIED

#5 Updated by ttereshc 4 months ago

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

Please register to edit this issue

Also available in: Atom PDF