apigee / apigee-api-catalog-drupal

Manage your API catalog within Drupal's content management approach
https://www.drupal.org/project/apigee_api_catalog
GNU General Public License v2.0
17 stars 16 forks source link

Getting Error on API Documentation settings page #122

Closed nishasw closed 3 years ago

nishasw commented 3 years ago

Description

While accessing path /admin/structure/apidoc , I am getting the error below post installation of apigee kickstart module on both Drupal 8 & 9

The website encountered an unexpected error. Please try again later.

InvalidArgumentException: Class "Drupal\apigee_api_catalog\Entity\Form\ApiDocSettingsForm" does not exist. in Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (line 24 of core\lib\Drupal\Core\DependencyInjection\ClassResolver.php). Drupal\Core\Controller\HtmlFormController->getFormObject(Object, 'Drupal\apigee_api_catalog\Entity\Form\ApiDocSettingsForm') (Line: 58) Drupal\Core\Controller\FormController->getContentResult(Object, Object) call_user_func_array(Array, Array) (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 573) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 158) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 706) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Any help to resolve this will greatly be appreciated.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Go to /admin/structure/apidoc and I get the error

image

shishir-intelli commented 3 years ago

Hi @nishasw ,

The entity API Doc has been converted to node type in the Apigee API Catalog module, Use the node "apidoc" bundle instead. You can configure it at (Structure > Content types > API Doc) in the admin menu and you can add new API docs under Content > API catalog in the admin menu.

For more information on configuring API Doc please check the README.md file.

We are working on removing the configure link which is leading to admin/structure/apidoc in Apigee API Catalog module.

nishasw commented 3 years ago

Hi @shishir-intelli. Thanks for your reply. In Drupal 7, we had settings for the SmartDocs proxy URL, how do we achieve the same in Drupal 8 & 9 ? In Drupal 7, when we uploaded the OpenSpecification file, the methods from those file used to get rendered as nodes to which we were then able to edit manually if required, also there were security settings to get enabled, how do we do it in Drupal 8&9 ?

shishir-intelli commented 3 years ago

@nishasw in drupal 8/9 entity API Doc is a node type and so you can manage the apidocs in node itself,

Follow this steps to upload OpenSpecification file,

or you can select a url from the drop down and then enter the full file URL under URL to OpenAPI specification file.

If you want to edit the file later you can reimport a new file or link to a new URL by clicking Remove under OpenAPI specifications file, uploading a new spec snapshot or URL, and then clicking Save.

(Also you can create your own custom field formatter to create a renderer of your choice. This can be useful to plugin other libraries to visualize your specifications. Currently you can use SmartDocs, Swagger UI or Redoc to render your API Documentation. instructions)

For security setting you can refer here

For control access to your api doc you can

For control access to api catalog page you can

If you are trying achieve something else apart from this please feel free to elaborate the same .

nishasw commented 3 years ago

Hi @shishir-intelli ,

Thanks for your reply.

How can we set OAuth by choosing app [like we had in Drupal 7 ] instead of entering client credentials manually ?

shishir-intelli commented 3 years ago

Hi @nishasw,

I am not sure what you meant by 'Oauth by choosing app'? Did you mean to say API? Can you please elaborate more or possibly share screenshots or urls of Drupal 7 so i can help you better and guide you to setup Oauth on drupal 8/9.

nishasw commented 3 years ago

@shishir-intelli ,

Please see the attached screenshot from Drupal 7 . In Drupal 7, while sending the request to test sandbox services on portal, if needed to set OAuth, we used to select apps from the dropdown but in Drupal 8/9 we need to enter the app credentials manually. So , how do we enable app selection instead of entering app credential manually in the dropdown of Authorizing the request.

Drupal 8/9 image

Drupal 7 image

shishir-intelli commented 3 years ago

Hi @nishasw, Thanks for the details,

In Drupal 7, it was managed by node however, it was originally defined in the OpenSpecification file which you upload and in this file it is defined as security scheme/Authorization setting.

In Drupal 8/9, you create a node for API doc (Content->Add Content -> API Doc) and upload the OpenSpecification file there. In Open Specification file, you will have to mention the security scheme for OAuth 2.0, In the screenshot which you have shared above for drupal 8/9 shows that you have "clientCredentials" as flow for security scheme in your Open Specification file which should be "authorizationCode" in your case. OAuth flow can be (authorizationCode, implicit, password or clientCredentials)

Security schema example:

{
  "type": "oauth2",
  "flows": {
    "authorizationCode": {     # <---- OAuth flow(authorizationCode, implicit, password or clientCredentials)
      "authorizationUrl": "https://example.com/api/oauth/dialog",
      "tokenUrl": "https://example.com/api/oauth/token",
      "scopes": {
        "write:pets": "modify pets in your account",
        "read:pets": "read your pets"
      }
    }
  }
}

So basically you can manage this from OpenSpecification file by changing the OAuth structure to use authorizationCode
In Drupal 8/9 there is no option to do this from UI, (Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0.)

For authorizationCode reference checkout : https://swagger.io/docs/specification/authentication/oauth2/

nishasw commented 3 years ago

Hi @shishir-intelli ,

Thanks for you assistance. Really appreciate.

nishasw commented 3 years ago

Hi @shishir-intelli ,

I have following two issues currently : 1 . I changed the flows to authorizationCode but it had no effect on the app name dropdown, still the input fields for Client ID and Client Secret is getting displayed. Please see the snapshots of my swagger snippet and popup on the portal :

image

image

  1. My request payload also doesn't get loaded. Do you have any idea why this might be the case :

image

Thanks in advance for your support.

cnovak commented 3 years ago

@nishasw can you put in separate issues for each of your problems? It is getting hard to follow this thread since you keep adding different problems to the same issue. API Doc issues should be added to the API Catalog module: https://github.com/apigee/apigee-api-catalog-drupal/issues

cnovak commented 3 years ago

For issue #2, it is a duplicate of: #67

raakesh-blokhra commented 3 years ago

Hi @nishasw I am looking at issue #123. Since @shishir-intelli has given steps to add API Doc, I'll close this ticket. Feel free to reopen in case you are still having any issues with creating API docs.

raakesh-blokhra commented 3 years ago

Since we don't have a configuration option for this feature anymore, the link in the admin needs for module config needs to be removed. Reopening this issue, will close with a PR.