Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Error on API Documentation settings page #122

Closed
nishasw opened this issue Jan 27, 2021 · 13 comments · Fixed by #131
Closed

Getting Error on API Documentation settings page #122

nishasw opened this issue Jan 27, 2021 · 13 comments · Fixed by #131
Assignees
Labels
bug Something isn't working

Comments

@nishasw
Copy link

nishasw commented Jan 27, 2021

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 shishir-intelli self-assigned this Feb 2, 2021
@shishir-intelli
Copy link
Collaborator

shishir-intelli commented Feb 2, 2021

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
Copy link
Author

nishasw commented Feb 2, 2021

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
Copy link
Collaborator

@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,

  • Navigate to Content > API Catalog in the Drupal admin menu.
  • Click +Add API Doc. The Add API Doc form will display
  • In "Specification source type" field select the file from the drop down and upload yaml/yml file which contains the methods and proxy url etc.

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

  • Navigate to People > Permissions > Apigee API Catalog > View published API docs in the Drupal admin menu.
  • Select the desired permissions for each user role.

For control access to api catalog page you can

  • Navigate to Structure > Views > API Catalog in the Drupal admin menu.
  • In the Page Settings section, click Access: Permission to configure access to the page based on permission or role.

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

@nishasw
Copy link
Author

nishasw commented Feb 3, 2021

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
Copy link
Collaborator

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
Copy link
Author

nishasw commented Feb 4, 2021

@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
Copy link
Collaborator

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
Copy link
Author

nishasw commented Feb 5, 2021

Hi @shishir-intelli ,

Thanks for you assistance. Really appreciate.

@nishasw
Copy link
Author

nishasw commented Feb 15, 2021

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
Copy link
Collaborator

cnovak commented Feb 16, 2021

@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 cnovak transferred this issue from apigee/apigee-devportal-kickstart-drupal Feb 16, 2021
@cnovak
Copy link
Collaborator

cnovak commented Feb 16, 2021

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

@raakesh-blokhra
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants