Создание документации API с использованием Swagger - PullRequest
0 голосов
/ 27 января 2020

Я написал следующий код в yaml для вызова стандартного API Salesforce из swagger.

openapi: 3.0.0
info:
  title: Salesforce Standard API
  description: Salesforce Standard API
  version: 1.0.2
servers:
  - url: https://jpdocusign-dev-ed.my.salesforce.com
    description: Developer Org Base URL
components:
  securitySchemes:
    OAuth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://jpdocusign-dev-ed.my.salesforce.com/services/oauth2/authorize?response_type=code&redirect_uri=https://jpdocusign-dev-ed--c.na174.visual.force.com/apex/RedirectVF
          tokenUrl: https://login.salesforce.com/services/oauth2/token
          scopes:
            read: Grants read access
            write: Grants write access
            admin: Grants access to admin operations
paths:
  /services/data/v45.0/sobjects/Account/{id}:
    get:
      summary: Returns an Account having the Id, we pass.
      description: Returns an Account having the Id, we pass.
      security:
        - OAuth2: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':    # status code
          description: Account details in JSON format
          content:
            application/json:
              schema: 
                type: object
                items: 
                  required:
                   - Id
                  properties:
                    attributes:
                      type: object
                    Id:
                      type: string
                    IsDeleted:
                      type: boolean
                    MasterRecordId:
                      type: string
                    Name:
                      type: string
                    Type:
                      type: string

После нажатия кнопки «Авторизовать» возвращается код авторизации. На следующем шаге я должен получить токен доступа для дальнейших запросов, таких как GET, POST и т. Д. c. Как получить токен доступа?

...