Skip to content

Instantly share code, notes, and snippets.

@blide
Last active May 17, 2016 22:22
Show Gist options
  • Save blide/2cbdbb6cceb36a708ce8873ae2d205e4 to your computer and use it in GitHub Desktop.
Save blide/2cbdbb6cceb36a708ce8873ae2d205e4 to your computer and use it in GitHub Desktop.

Revisions

  1. blide revised this gist May 17, 2016. 1 changed file with 55 additions and 2 deletions.
    57 changes: 55 additions & 2 deletions swagger.yaml
    Original file line number Diff line number Diff line change
    @@ -120,6 +120,14 @@ paths:
    tags:
    - Campaigns
    - Authorized
    consumes:
    - application/json
    parameters:
    - name: body
    in: body
    required: true
    schema:
    $ref: "#/definitions/CampaignMutable"
    responses:
    200:
    description: ""
    @@ -167,6 +175,14 @@ paths:
    - Campaigns
    - Creatives
    - Authorized
    consumes:
    - application/json
    parameters:
    - name: body
    in: body
    required: true
    schema:
    $ref: "#/definitions/CreativeMutable"
    responses:
    200:
    description: ""
    @@ -206,6 +222,14 @@ paths:
    - Campaigns
    - Creatives
    - Authorized
    consumes:
    - application/json
    parameters:
    - name: body
    in: body
    required: true
    schema:
    $ref: "#/definitions/CreativeMutable"
    responses:
    200:
    description: ""
    @@ -240,7 +264,11 @@ definitions:
    Campaign:
    allOf:
    - $ref: "#/definitions/CampaignMutable"
    - properties:
    - required:
    - id
    - user_id
    - audit_status
    properties:
    id:
    type: integer
    user_id:
    @@ -250,6 +278,24 @@ definitions:

    CampaignMutable:
    type: object
    required:
    - name
    - url
    - categories
    - domain
    - start_date
    - end_date
    - total_budget
    - daily_budget
    - hourly_budget
    - appdaily_budget
    - bid_type
    - bid_price
    - bid_price_min
    - roi_limit
    - status
    - freq_capping
    - ssps
    properties:
    name:
    type: string
    @@ -347,7 +393,11 @@ definitions:
    Creative:
    allOf:
    - $ref: "#/definitions/CreativeMutable"
    - properties:
    - required:
    - id
    - campaign_id
    - audit_status
    properties:
    id:
    type: integer
    campaign_id:
    @@ -357,6 +407,9 @@ definitions:

    CreativeMutable:
    type: object
    required:
    - name
    - status
    properties:
    name:
    type: string
  2. blide renamed this gist May 17, 2016. 1 changed file with 117 additions and 13 deletions.
    130 changes: 117 additions & 13 deletions gistfile1.txt → swagger.yaml
    Original file line number Diff line number Diff line change
    @@ -88,13 +88,8 @@ paths:
    in: body
    required: true
    schema:
    type: object
    properties:
    name:
    type: string
    example:
    alo:
    alo: dfdf
    $ref: "#/definitions/CampaignMutable"

    responses:
    200:
    description: ""
    @@ -243,21 +238,130 @@ paths:
    definitions:

    Campaign:
    allOf:
    - $ref: "#/definitions/CampaignMutable"
    - properties:
    id:
    type: integer
    user_id:
    type: integer
    audit_status:
    type: integer

    CampaignMutable:
    type: object
    properties:
    id:
    name:
    type: string
    description: ID
    title:
    url:
    type: string
    description: Название кампании
    categories:
    type: array
    items:
    type: string
    domain:
    type: string
    start_date:
    type: integer
    end_date:
    type: integer
    total_budget:
    type: number
    format: float
    daily_budget:
    type: number
    format: float
    hourly_budget:
    type: number
    format: float
    appdaily_budget:
    type: number
    format: float
    bid_type:
    type: integer
    bid_price:
    type: number
    format: float
    bid_price_min:
    type: number
    format: float
    roi_limit:
    type: integer
    status:
    type: integer
    freq_capping:
    type: integer
    targeting:
    $ref: "#/definitions/Targeting"
    ssps:
    type: array
    items:
    type: string

    Targeting:
    type: object
    properties:
    location:
    $ref: "#/definitions/InEx"
    categories:
    $ref: "#/definitions/InEx"
    connection:
    type: integer
    os:
    $ref: "#/definitions/InEx"
    device_brand:
    $ref: "#/definitions/InEx"
    device_type:
    type: integer
    browser:
    $ref: "#/definitions/InEx"
    language:
    $ref: "#/definitions/InEx"
    isp:
    $ref: "#/definitions/InEx"
    ip_ranges:
    type: array
    items:
    type: array
    items:
    type: integer
    day_parting:
    type: array
    items:
    type: array
    items:
    type: boolean

    InEx:
    type: object
    properties:
    included:
    type: array
    items:
    type: integer
    excluded:
    type: array
    items:
    type: integer

    Creative:
    allOf:
    - $ref: "#/definitions/CreativeMutable"
    - properties:
    id:
    type: integer
    campaign_id:
    type: integer
    audit_status:
    type: integer

    CreativeMutable:
    type: object
    properties:
    id:
    name:
    type: string
    description: ID
    status:
    type: integer

    ValError:
    type: object
  3. blide created this gist May 17, 2016.
    312 changes: 312 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,312 @@
    swagger: '2.0'
    info:
    title: DSP API
    description: |
    Авторизаационный токен передается в хедере X-Authorization. При при попытке доступа к Authorized endpoint'ам неавторизованным клиентом status code = 401
    version: "1.0.0"
    # the domain of the service
    host: api.dsp.com
    # array of all schemes that your API supports
    schemes:
    - https
    # will be prefixed to all paths
    basePath: /v1
    produces:
    - application/json
    consumes:
    - application/json
    paths:
    /user/login:
    post:
    description: Авторизация
    parameters:
    - name: login
    in: query
    description: Пароль
    required: true
    type: string
    - name: password
    in: query
    description: Логин
    required: true
    type: string
    tags:
    - Users
    responses:
    200:
    description: Токен
    schema:
    $ref: '#/definitions/LoginResp'
    default:
    description: Ошибка
    schema:
    $ref: '#/definitions/Error'
    /me/logout:
    post:
    summary: Logout
    tags:
    - Users
    - Authorized
    responses:
    200:
    description: Пустой ответ
    /me/campaigns:
    get:
    summary: Список кампаний пользователя
    tags:
    - Campaigns
    - Authorized
    responses:
    200:
    description: Список кампаний на данной странице
    schema:
    type: object
    properties:
    count:
    type: integer
    description: Общее количество кампаний пользователя
    pages:
    type: integer
    description: Количество страниц
    page:
    type: integer
    description: Текущая страница
    campaigns:
    type: array
    items:
    $ref: "#/definitions/Campaign"
    /campaigns:
    post:
    summary: Создание новой кампании
    tags:
    - Campaigns
    - Authorized
    consumes:
    - application/json
    parameters:
    - name: body
    in: body
    required: true
    schema:
    type: object
    properties:
    name:
    type: string
    example:
    alo:
    alo: dfdf
    responses:
    200:
    description: ""
    schema:
    $ref: "#/definitions/ValResp"

    /campaigns/{campaignId}:
    parameters:
    - name: campaignId
    in: path
    description: ID кампании
    required: true
    type: string
    get:
    summary: Получение кампании с ID campaignId
    tags:
    - Campaigns
    - Authorized
    responses:
    200:
    description: ""
    schema:
    $ref: "#/definitions/Campaign"
    404:
    description: Кампания с таким ID не найдена
    put:
    summary: Изменение кампании
    tags:
    - Campaigns
    - Authorized
    responses:
    200:
    description: ""
    schema:
    $ref: "#/definitions/ValResp"
    404:
    description: Кампания с таким ID не найдена

    delete:
    summary: Удаление кампании(creativeId)
    tags:
    - Campaigns
    - Authorized
    responses:
    200:
    description: ""
    schema:
    $ref: "#/definitions/BoolResp"
    404:
    description: Кампания с таким ID не найдена

    /campaigns/{campaignId}/creatives:
    parameters:
    - name: campaignId
    in: path
    description: ID кампании
    required: true
    type: string
    get:
    summary: Список креативов кампании(campaignId)
    tags:
    - Campaigns
    - Creatives
    - Authorized
    responses:
    200:
    description: ""
    schema:
    $ref: "#/definitions/Creative"
    404:
    description: Кампания с таким ID не найдена
    post:
    summary: Добавление креатива в кампанию(campaignId)
    tags:
    - Campaigns
    - Creatives
    - Authorized
    responses:
    200:
    description: ""
    schema:
    $ref: "#/definitions/ValResp"
    404:
    description: Кампания с таким ID не найдена

    /campaigns/{campaignId}/creatives/{creativeId}:
    parameters:
    - name: campaignId
    in: path
    description: ID кампании
    required: true
    type: string
    - name: creativeId
    in: path
    description: ID креатива
    required: true
    type: string
    get:
    summary: Получение креатива(creativeId)
    tags:
    - Campaigns
    - Creatives
    - Authorized
    responses:
    200:
    description: ""
    schema:
    $ref: "#/definitions/Creative"
    404:
    description: Кампания с таким ID не найдена
    put:
    summary: Изменения креатива(creativeId)
    tags:
    - Campaigns
    - Creatives
    - Authorized
    responses:
    200:
    description: ""
    schema:
    type: object
    properties:
    success:
    type: boolean
    description: true, если изменение креатива прошло успешно, иначе false
    val_errors:
    type: array
    items:
    $ref: "#/definitions/ValError"
    404:
    description: Креатив с таким ID не найден
    delete:
    summary: Удаление креатива(creativeId)
    tags:
    - Campaigns
    - Creatives
    - Authorized
    responses:
    200:
    description: ""
    schema:
    $ref: "#/definitions/BoolResp"
    404:
    description: Кампания или креатив с таким ID не найдены

    definitions:

    Campaign:
    type: object
    properties:
    id:
    type: string
    description: ID
    title:
    type: string
    description: Название кампании

    Creative:
    type: object
    properties:
    id:
    type: string
    description: ID

    ValError:
    type: object
    description: |
    Если поле field пустое, то данная ошибка относится ко всем данным
    properties:
    field:
    type: string
    description: Название поля с ошибкой
    code:
    type: string
    description: Код ошибки(строка), используется как идентификатор

    Error:
    type: object
    properties:
    code:
    type: integer
    fields:
    type: string

    LoginResp:
    type: object
    properties:
    success:
    type: boolean
    description: true, если авторизация прошла успешно, иначе false
    access_token:
    type: string
    description: Токен, который будет использоваться для аутентификации пользователя
    expires:
    type: integer
    format: int32
    description: timestamp Дата, до которой токен будет действителен

    ValResp:
    type: object
    properties:
    success:
    type: boolean
    description: true, если операция прошла успешно, иначе false
    val_errors:
    type: array
    items:
    $ref: "#/definitions/ValError"

    BoolResp:
    type: object
    properties:
    success:
    type: boolean
    description: true, если операция прошла успешно, иначе false