8000 The openapi-internal.json does not reflect the actual internal api endpoint paths · Issue #957 · cloudigrade/cloudigrade · GitHub
[go: up one dir, main page]

Skip to content
The openapi-internal.json does not reflect the actual internal api endpoint paths #957
@abellotti

Description

@abellotti

Summary

The generated paths in the openapi-internal.json do not reflect the actual internal api endpoint paths.
For example you see:

{
  "openapi": "3.0.2",
  "info": {
     "title": "Cloudigrade internal API",
      "version": ""
   },
   "paths": {
     "/api/cloudigrade/v1/accounts/": {
       "get": {
          "operationId": "listAccounts",
...

Where the paths should include the /internal prefix, so in the above snippet, it should be /internal/api/cloudigrade/v1/accounts/

Steps to Reproduce

$ poetry run make openapi

The generated openapi-internal.json file paths are missing the /internal prefix.

Expected Result

{
  "openapi": "3.0.2",
  "info": {
     "title": "Cloudigrade internal API",
      "version": ""
   },
   "paths": {
     "/internal/api/cloudigrade/v1/accounts/": {
       "get": {
          "operationId": "listAccounts",
...

Additional Context

As per the DRF documentation for get_schema_view in https://www.django-rest-framework.org/api-guide/schemas/#get_schema_view, the fix should simply be to add a canonical base URL for the schema
via the url parameter.

So calling get_schema_view in https://github.com/cloudigrade/cloudigrade/blob/master/cloudigrade/internal/urls.py as follows should have done the trick, but it did not:

          get_schema_view(
              title="Cloudigrade Internal API",
              renderer_classes=[renderers.JSONOpenAPIRenderer],
              permission_classes=[permissions.AllowAny],
              authentication_classes=[],
              public=True,
+             url="internal/",
              urlconf="internal.urls",
          ),  

For reference, see:

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0