Discussions

Ask a Question
Back to All

Required enums for optional object always prefill body request.

Hi team.

I have swagger 2.0 file https://prod.truv.com/swagger.json with one of the definitions like this (excerpt schema):

{                                                                                                                       
  "definitions": {                                                                                                      
    "EmployerCreate": {                                                                                                 
      "type": "object",                                                                                                 
      "properties": {                                                                                                   
        "company_name": {                                                                                               
          "description": "Company name",                                                                                
          "type": "string",                                                                                             
          "example": "Facebook Demo"                                                                                    
        },                                                                                                              
        "account": {                                                                                                    
          "description": "Bank account info. Used for Direct deposit switching and Paycheck linked lending",            
          "required": [                                                                                                 
            "account_number",                                                                                           
            "account_type",                                                                                             
            "routing_number",                                                                                           
            "bank_name",                                                                                                
            "deposit_type"                                                                                              
          ],                                                                                                            
          "type": "object",                                                                                             
          "properties": {                                                                                               
            "account_number": {                                                                                         
              "description": "Account number",                                                                          
              "type": "string",                                                                                         
              "example": "16002600"                                                                                     
            },                                                                                                          
            "account_type": {                                                                                           
              "description": "\nAccount type:\n\n* `checking` - Checking account,\n* `savings` - Savings account\n\n",  
              "type": "string",                                                                                         
              "enum": [                                                                                                 
                "checking",                                                                                             
                "savings"                                                                                               
              ],                                                                                                        
              "example": "checking"                                                                                     
            },                                                                                                          
            "routing_number": {                                                                                         
              "description": "Routing number",                                                                          
              "type": "string",                                                                                         
              "example": "123456789"                                                                                    
            },                                                                                                          
            "bank_name": {                                                                                              
              "description": "Bank name",                                                                               
              "type": "string",                                                                                         
              "example": "TD Bank"                                                                                      
            },                                                                                                          
            "deposit_type": {                                                                                           
              "description": "\nDeposit type:\n\n* `entire` - Entire paycheck,\n* `percent` - Percentage of the paycheck,\n* `amount` - Fixed amount from the paycheck\n\n",
              "type": "string",                                                                                         
              "enum": [                                                                                                 
                "entire",                                                                                               
                "percent",                                                                                              
                "amount"                                                                                                
              ],                                                                                                        
              "example": "percent"                                                                                      
            },                                                                                                          
            "deposit_value": {                                                                                          
              "description": "Deposit value",                                                                           
              "type": "string",                                                                                         
              "example": "50.00"                                                                                        
            }                                                                                                           
          }                                                                                                             
        }                                                                                                               
      }                                                                                                                 
    }                                                                                                                   
  }                                                                                                                     
} 

My issue is that when I add this object in the list of object on the page https://docs.truv.com/reference/orders_create field "account" always added in the request example. E.g.:

curl --request POST \
     --url https://prod.truv.com/v1/orders/ \
     --header 'X-Access-Client-Id: xxx' \
     --header 'X-Access-Secret: sandbox-xxx' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "employers": [
    {
      "account": {
        "account_type": "checking",
        "deposit_type": "entire"
      }
    }
  ]
}

Which is wrong for our logic. Seems like required enums account_type and deposit_type is the case of the behavior. They are truly required when object account is provided. But the account object itself is optional for most of our cases. Any tips on how to suppress auto-adding of the account object?

Desired result is:

curl --request POST \
     --url https://prod.truv.com/v1/orders/ \
     --header 'X-Access-Client-Id: xxx' \
     --header 'X-Access-Secret: sandbox-xxx' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "employers": [
    {
      "company_name": "Some company"
    }
  ]
}

I tried several combinations of default/example parameters, but only thing that works is to make enums account_type and deposit_type optional (which is wrong for our API).

Thank for help in advance!