Forum Discussion

Stoplight's avatar
Stoplight
Community Manager
2 months ago

Using slugs to access directly endpoints

Originally posted by user HHChift to the Stoplight Community on 01/16/2023 at 11:10 ET.

Hey all,

I would like to be able from an external website to have links to specific endpoints in my documentation based on the OpenAPI schema of my API.

I'm following this tutorial: https://meta.stoplight.io/docs/platform/hosted-docs/stoplight-urls

I've defined slugs on my API so that I can access an endpoint directly with for example: docs/{project-slug}/payments-api/operations/get-a-user

But I'm not able to find from where from the openapi spec the "get-a-user" part is retrieved ?

The operationId of my specifications do not match with the operationId in the URLs , any idea how I can fix this ?

Thanks.

2 Replies

  • Stoplight's avatar
    Stoplight
    Community Manager

    a_welch (Staff) [01/20/2023 - 17:10 ET]

    Thank you for reaching out. I did some digging on this and if you look at the code view of your API you will see there is a Summary and an OperationID. The slug is referencing the Summary of the API spec not the OperationID. Here is an example to show you the 2 rows, Summary at the top and OperationID at the bottom:

    get:
          summary: Get User Info by User ID
          tags:
            - users
          responses:
            '200':
              description: User Found
              content:
                application/json:
                  schema:
                    $ref: '#/components/schemas/User'
                  examples:
                    Get User Alice Smith:
                      value:
                        id: 142
                        firstName: Alice
                        lastName: Smith
                        email: alice.smith@gmail.com
                        dateOfBirth: '1997-10-31'
                        emailVerified: true
                        signUpDate: '2019-08-24'
            '404':
              description: User Not Found
          operationId: get-users-userId

    I hope that helps clarify this for you!

    • Stoplight's avatar
      Stoplight
      Community Manager

      HHChift (OP) [01/26/2023 - 11:29 ET]

      Hey Thanks for your response. I'm not sure I follow completely our answer. 

      The route to this page in Stoplight is ending as follows: api/operations/list-consumers

      It does not match with the operationId neither with the summary. We would like to be able to open the link to the documentation based on the openApi spec.