Swagger generated files of YNAB Python APIs missing data types
Hello there,
For the YNAB personal budgeting tool, I am trialling access with some Python script. Using YNAB's JSON API specification from https://api.youneedabudget.com/papi/spec-v1-swagger.json I fed the data to the Swagger Editor at https://editor.swagger.io/ and generated Python APIs for client use.
Generally APIs are working fine, authorisation is successful and am able to retrieve data. But I noticed the API for GET /budgets/{budget_id}/months/{month} is incorrectly defined in the generated Py file, but I haven't tested the other API and they could also be affected.
According to YNAB's documentation for this GET API given at https://api.youneedabudget.com/v1#/Months/getBudgetMonth the response data should have several values in 'month'. But the data fields highlighted red text below don't appear in the response! When I dug deeper and inspected the generated file month_detail.py I only saw 'categories: list[]' as the only attribute in the MonthDetail class. The ones shown in the documentation are missing. The JSON API spec fed to the Swagger Editor, also shows the highlighted data fields are included in the MonthDetail class.
Can someone please help to clarify why these fields don't appear in the generated code?
Thanks
Response data documentation for GET /budgets/{budget_id}/months/{month} from YNAB
{ "data": { "month": { "month": "string", "note": "string", "income": 0, "budgeted": 0, "activity": 0, "to_be_budgeted": 0, "age_of_money": 0, "deleted": true, "categories": [ { "id": "string", "category_group_id": "string", "name": "string", "hidden": true, "original_category_group_id": "string", "note": "string", "budgeted": 0, "activity": 0, "balance": 0, "goal_type": "TB", "goal_creation_month": "string", "goal_target": 0, "goal_target_month": "string", "goal_percentage_complete": 0, "deleted": true } ] } } }
JSON file extract from YNAB showing the MonthDetail data fields. Data from MonthSummary are completely missing in the generated code.
"MonthSummary": { "type": "object", "required": ["month", "income", "budgeted", "activity", "to_be_budgeted", "deleted"], "properties": { "month": { "type": "string", "format": "date" }, "note": { "type": "string" }, "income": { "type": "integer", "format": "int64", "description": "The total amount of transactions categorized to 'Inflow: To be Budgeted' in the month" }, "budgeted": { "type": "integer", "format": "int64", "description": "The total amount budgeted in the month" }, "activity": { "type": "integer", "format": "int64", "description": "The total amount of transactions in the month, excluding those categorized to 'Inflow: To be Budgeted'" }, "to_be_budgeted": { "type": "integer", "format": "int64", "description": "The available amount for 'To be Budgeted'" }, "age_of_money": { "type": "integer", "format": "int32", "description": "The Age of Money as of the month" }, "deleted": { "type": "boolean", "description": "Whether or not the month has been deleted. Deleted months will only be included in delta requests." } } },
"MonthDetail": { "allOf": [ { "$ref": "#/definitions/MonthSummary" }, { "type": "object", "required": ["categories"], "properties": { "categories": { "type": "array", "description": "The budget month categories. Amounts (budgeted, activity, balance, etc.) are specific to the {month} parameter specified.", "items": { "$ref": "#/definitions/Category" } } } } ] }
And an extract of the generated month_detail.py file:
# coding: utf-8
"""
YNAB API Endpoints
Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.youneedabudget.com # noqa: E501
OpenAPI spec version: 1.0.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
import pprint
import re # noqa: F401
import six
class MonthDetail(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
swagger_types = {
'categories': 'list[Category]'
}
attribute_map = {
'categories': 'categories'
}
def __init__(self, categories=None): # noqa: E501
"""MonthDetail - a model defined in Swagger""" # noqa: E501
self._categories = None
self.discriminator = None
self.categories = categories