RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.82k stars 1.3k forks source link

Can't import convert open banking API swagger specification file to CSharp client #1913

Open crookedbard opened 5 years ago

crookedbard commented 5 years ago
{
    "basePath": "/sandbox/v1",
    "definitions": {
        "AccountResponse": {
            "properties": {
                "description": "A list of accounts objects",
                "items": {
                    "properties": {
                        "accountID": {
                            "type": "string"
                        },
                        "balance": {
                            "type": "number"
                        },
                        "currency": {
                            "type": "string"
                        }
                    },
                    "type": "object"
                },
                "type": "array"
            },
            "required": [
                "account_list"
            ],
            "type": "object"
        },
        "accessAllAccounts": {
            "properties": {
                "accounts": {
                    "description": "A list of accounts objects",
                    "items": {
                        "properties": {
                            "accountID": {
                                "type": "string"
                            },
                            "balance": {
                                "type": "number"
                            },
                            "currency": {
                                "type": "string"
                            }
                        },
                        "type": "object"
                    },
                    "type": "array"
                },
                "allPsd2": {
                    "enum": [
                        "allAccounts"
                    ],
                    "type": "string"
                },
                "availableAccounts": {
                    "enum": [
                        "allAccounts"
                    ],
                    "type": "string"
                },
                "balances": {
                    "description": "A list of accounts objects",
                    "items": {
                        "properties": {
                            "accountID": {
                                "type": "string"
                            },
                            "balance": {
                                "type": "number"
                            },
                            "currency": {
                                "type": "string"
                            }
                        },
                        "type": "object"
                    },
                    "type": "array"
                },
                "transactions": {
                    "description": "A list of accounts objects",
                    "items": {
                        "properties": {
                            "accountID": {
                                "type": "string"
                            },
                            "balance": {
                                "type": "number"
                            },
                            "currency": {
                                "type": "string"
                            }
                        },
                        "type": "object"
                    },
                    "type": "array"
                }
            },
            "type": "object"
        },
        "account": {
            "properties": {
                "accountID": {
                    "type": "string"
                },
                "balance": {
                    "type": "number"
                },
                "currency": {
                    "type": "string"
                }
            },
            "type": "object"
        },
        "accountList": {
            "description": "A list of accounts objects",
            "items": {
                "properties": {
                    "accountID": {
                        "type": "string"
                    },
                    "balance": {
                        "type": "number"
                    },
                    "currency": {
                        "type": "string"
                    }
                },
                "type": "object"
            },
            "type": "array"
        },
        "allAccounts": {
            "properties": {
                "access": {
                    "properties": {
                        "accounts": {
                            "description": "A list of accounts objects",
                            "items": {
                                "properties": {
                                    "accountID": {
                                        "type": "string"
                                    },
                                    "balance": {
                                        "type": "number"
                                    },
                                    "currency": {
                                        "type": "string"
                                    }
                                },
                                "type": "object"
                            },
                            "type": "array"
                        },
                        "allPsd2": {
                            "enum": [
                                "allAccounts"
                            ],
                            "type": "string"
                        },
                        "availableAccounts": {
                            "enum": [
                                "allAccounts"
                            ],
                            "type": "string"
                        },
                        "balances": {
                            "description": "A list of accounts objects",
                            "items": {
                                "properties": {
                                    "accountID": {
                                        "type": "string"
                                    },
                                    "balance": {
                                        "type": "number"
                                    },
                                    "currency": {
                                        "type": "string"
                                    }
                                },
                                "type": "object"
                            },
                            "type": "array"
                        },
                        "transactions": {
                            "description": "A list of accounts objects",
                            "items": {
                                "properties": {
                                    "accountID": {
                                        "type": "string"
                                    },
                                    "balance": {
                                        "type": "number"
                                    },
                                    "currency": {
                                        "type": "string"
                                    }
                                },
                                "type": "object"
                            },
                            "type": "array"
                        }
                    },
                    "type": "object"
                },
                "combinedServiceIndicator": {
                    "type": "boolean"
                },
                "frequencyPerDay": {
                    "type": "number"
                },
                "recurringIndicator": {
                    "type": "boolean"
                },
                "validUntil": {
                    "format": "date-time",
                    "type": "string"
                }
            },
            "required": [
                "recurringIndicator",
                "validUntil",
                "access"
            ],
            "type": "object"
        },
        "bic": {
            "description": "Bank Identifer Code",
            "enum": [
                "SANDSESS",
                "SANDEE2X",
                "SANDLT22",
                "SANDLV22"
            ],
            "type": "string"
        }
    },
    "externalDocs": {
        "description": "Find out more about Swagger",
        "url": "http://swagger.io"
    },
    "host": "psd2.api.swedbank.com:443",
    "info": {
        "contact": {
            "email": "openbanking@swedbank.com"
        },
        "description": "This is used to get information about accounts connected to a customer. A prerequisite for querying is that consent is collected already and consent information is passed in the request. In all our queries a bic code is mandatory to specify in order to route the request to the correct backend. Please note that Swedbank Sweden and cooperating Savings Banks share the same bic.",
        "license": {
            "name": "See Developer Documentation",
            "url": "https://www.swedbank.com/idc/groups/public/@i/@sc/@all/@kp/documents/regulation/cid_2441155.pdf"
        },
        "title": "Account Information Services API",
        "version": "2.1.0"
    },
    "parameters": {
        "Authorization": {
            "description": "Security header",
            "in": "header",
            "name": "Authorization",
            "required": true,
            "type": "string"
        },
        "Consent-ID": {
            "description": "ID of the consent which granted access to specified accountID.",
            "format": "UUID",
            "in": "header",
            "name": "Consent-ID",
            "required": true,
            "type": "integer"
        },
        "Date": {
            "description": "Standard https header element date and time",
            "format": "date-time",
            "in": "header",
            "name": "Date",
            "required": true,
            "type": "string"
        },
        "PSU-IP-Address": {
            "description": "The forwarded IP Address header field consists of the corresponding http request IP Address field between PSU and TPP.",
            "in": "header",
            "name": "PSU-IP-Address",
            "required": true,
            "type": "string"
        },
        "X-Request-ID": {
            "description": "ID of the transaction as determined by the initiating party.",
            "format": "UUID",
            "in": "header",
            "name": "X-Request-ID",
            "required": true,
            "type": "string"
        },
        "app-id": {
            "description": "API Key (Client ID) from Swedbank developer portal",
            "format": "UUID",
            "in": "query",
            "name": "app-id",
            "required": true,
            "type": "integer"
        },
        "bic": {
            "description": "Bank Identifer Code \nAllowed values = [SANDSESS, SANDEE2X, SANDLT22, SANDLV22]",
            "enum": [
                "SANDSESS",
                "SANDEE2X",
                "SANDLT22",
                "SANDLV22"
            ],
            "in": "query",
            "name": "bic",
            "required": true,
            "type": "string"
        },
        "content-type": {
            "description": "application/json",
            "in": "header",
            "name": "Content-Type",
            "required": true,
            "type": "string"
        },
        "psu-involved": {
            "description": "If contained, it is indicated that a PSU har directly asked this account access in real-time. The PSU then might be involved in an additional consent process, if the given consent is not any more sufficient",
            "in": "query",
            "name": "psuInvolved",
            "type": "boolean"
        }
    },
    "paths": {
        "/accounts/": {
            "get": {
                "consumes": [
                    "application/json"
                ],
                "description": "Read the identifiers of the available payment account together with booking balance information, depending on the consent granted.It is assumed that a consent of the PSU to this access is already given and stored on the ASPSP system. The addressed list of accounts depends then on the PSU ID and the stored consent addressed by consentId, respectively the OAuth2 access token.Returns all identifiers of the accounts, to which an account access has been granted to through the /consents endpoint by the PSU. In addition, relevant information about the accounts and hyperlinks to corresponding account information resources are provided if a related consent has been already granted.Remark: Note that the /consents endpoint optionally offers to grant an access on all available payment accounts of a PSU. In this case, this endpoint will deliver the information about all available payment accounts of the PSU at this ASPSP.",
                "operationId": "getAccounts",
                "parameters": [
                    {
                        "description": "Bank Identifer Code \nAllowed values = [SANDSESS, SANDEE2X, SANDLT22, SANDLV22]",
                        "enum": [
                            "SANDSESS",
                            "SANDEE2X",
                            "SANDLT22",
                            "SANDLV22"
                        ],
                        "in": "query",
                        "name": "bic",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "Standard https header element date and time",
                        "format": "date-time",
                        "in": "header",
                        "name": "Date",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "Security header",
                        "in": "header",
                        "name": "Authorization",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "ID of the request, unique to the call, as determined by the initiating party.",
                        "format": "UUID",
                        "in": "header",
                        "name": "X-Request-ID",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "ID of the consent which granted access to specified accountID.",
                        "format": "UUID",
                        "in": "header",
                        "name": "Consent-ID",
                        "required": true,
                        "type": "integer"
                    }
                ],
                "produces": [
                    "application/json"
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "400": {
                        "description": "Bad request"
                    },
                    "401": {
                        "description": "Unauthorized: missing token or it's expired"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "404": {
                        "description": "Not found"
                    },
                    "405": {
                        "description": "Not allowed HTTP method"
                    },
                    "429": {
                        "description": "Access exceeded - too many requests"
                    },
                    "500": {
                        "description": "Internal Server Error"
                    }
                },
                "summary": "List Accounts",
                "tags": [
                    "accounts"
                ]
            }
        },
        "/accounts/{accountID}/": {
            "get": {
                "consumes": [
                    "application/json"
                ],
                "description": "Reads details about an account, with balances where required. It is assumed that a consent of the PSU to this access is already given and stored on the ASPSP system. The addressed details of this account depends then on the stored consent addressed by consentId, respectively the OAuth2 access token. NOTE: The account-id can represent a multi currency account. In this case the currency code is set to XXX.Give detailed information about the addressed account.Give detailed information about the addressed account together with balance information",
                "operationId": "getAccountID",
                "parameters": [
                    {
                        "description": "Get detailed view of this account id: for Baltic countries it's IBAN, for Sweden - it's account ID",
                        "in": "path",
                        "name": "accountID",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "Bank Identifer Code \nAllowed values = [SANDSESS, SANDEE2X, SANDLT22, SANDLV22]",
                        "enum": [
                            "SANDSESS",
                            "SANDEE2X",
                            "SANDLT22",
                            "SANDLV22"
                        ],
                        "in": "query",
                        "name": "bic",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "Standard https header element date and time",
                        "format": "date-time",
                        "in": "header",
                        "name": "Date",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "Security header",
                        "in": "header",
                        "name": "Authorization",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "ID of the request, unique to the call, as determined by the initiating party.",
                        "format": "UUID",
                        "in": "header",
                        "name": "X-Request-ID",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "ID of the consent which granted access to specified accountID.",
                        "format": "UUID",
                        "in": "header",
                        "name": "Consent-ID",
                        "required": true,
                        "type": "integer"
                    }
                ],
                "produces": [
                    "application/json"
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "400": {
                        "description": "Bad request"
                    },
                    "401": {
                        "description": "Unauthorized: missing token or it's expired"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "404": {
                        "description": "Not found"
                    },
                    "405": {
                        "description": "Not allowed HTTP method"
                    },
                    "429": {
                        "description": "Access exceeded - too many requests"
                    },
                    "500": {
                        "description": "Internal Server Error"
                    }
                },
                "summary": "List specific account",
                "tags": [
                    "accounts"
                ]
            }
        },
        "/accounts/{accountID}/balances/": {
            "get": {
                "consumes": [
                    "application/json"
                ],
                "description": "Read balance report of a given account addressed by accountID.",
                "operationId": "getAccountIDBalances",
                "parameters": [
                    {
                        "description": "Get detailed view of this account id",
                        "in": "path",
                        "name": "accountID",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "Bank Identifer Code \nAllowed values = [SANDSESS, SANDEE2X, SANDLT22, SANDLV22]",
                        "enum": [
                            "SANDSESS",
                            "SANDEE2X",
                            "SANDLT22",
                            "SANDLV22"
                        ],
                        "in": "query",
                        "name": "bic",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "Standard https header element date and time",
                        "format": "date-time",
                        "in": "header",
                        "name": "Date",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "Security header",
                        "in": "header",
                        "name": "Authorization",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "ID of the request, unique to the call, as determined by the initiating party.",
                        "format": "UUID",
                        "in": "header",
                        "name": "X-Request-ID",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "ID of the consent which granted access to specified accountID.",
                        "format": "UUID",
                        "in": "header",
                        "name": "Consent-ID",
                        "required": true,
                        "type": "integer"
                    }
                ],
                "produces": [
                    "application/json"
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "400": {
                        "description": "Bad request"
                    },
                    "401": {
                        "description": "Unauthorized: missing token or it's expired"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "404": {
                        "description": "Not found"
                    },
                    "405": {
                        "description": "Not allowed HTTP method"
                    },
                    "429": {
                        "description": "Access exceeded - too many requests"
                    },
                    "500": {
                        "description": "Internal Server Error"
                    }
                },
                "summary": "Read balances",
                "tags": [
                    "accounts"
                ]
            }
        },
        "/accounts/{accountID}/transactions/": {
            "get": {
                "consumes": [
                    "application/json"
                ],
                "description": "Read transaction reports or transaction lists of a given account addressed by accountID, depending on the steering parameter bookingStatus together with balances.For a given account, additional parameters are e.g. the attributes dateFrom and dateTo. The ASPSP might add balance information, if transaction lists without balances are not supported.",
                "operationId": "getAccountIDTransactions",
                "parameters": [
                    {
                        "description": "Get detailed view of this account id",
                        "in": "path",
                        "name": "accountID",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "Bank Identifer Code \nAllowed values = [SANDSESS, SANDEE2X, SANDLT22, SANDLV22]",
                        "enum": [
                            "SANDSESS",
                            "SANDEE2X",
                            "SANDLT22",
                            "SANDLV22"
                        ],
                        "in": "query",
                        "name": "bic",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "Standard https header element date and time",
                        "format": "date-time",
                        "in": "header",
                        "name": "Date",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "Security header",
                        "in": "header",
                        "name": "Authorization",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "ID of the request, unique to the call, as determined by the initiating party.",
                        "format": "UUID",
                        "in": "header",
                        "name": "X-Request-ID",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "ID of the consent which granted access to specified accountID.",
                        "format": "UUID",
                        "in": "header",
                        "name": "Consent-ID",
                        "required": true,
                        "type": "integer"
                    },
                    {
                        "description": "Starting date of the account statement",
                        "format": "date-time",
                        "in": "query",
                        "name": "dateFrom",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "Get transactions to this date",
                        "format": "date-time",
                        "in": "query",
                        "name": "dateTo",
                        "required": true,
                        "type": "string"
                    }
                ],
                "produces": [
                    "application/json"
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "400": {
                        "description": "Bad request"
                    },
                    "401": {
                        "description": "Unauthorized: missing token or it's expired"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "404": {
                        "description": "Not found"
                    },
                    "405": {
                        "description": "Not allowed HTTP method"
                    },
                    "429": {
                        "description": "Access exceeded - too many requests"
                    },
                    "500": {
                        "description": "Internal Server Error"
                    }
                },
                "summary": "Read transaction list",
                "tags": [
                    "accounts"
                ]
            }
        }
    },
    "schemes": [
        "https"
    ],
    "swagger": "2.0",
    "tags": [
        {
            "description": "The Account Information Service (AIS) offers the following services: Transaction reports for a given account including balances if applicable; Balances of a given account; A list of available accounts; Account details of a given account or of the list of all accessible accounts relative to a granted consent",
            "name": "accounts"
        }
    ]
}
RicoSuter commented 5 years ago

This is an invalid swagger spec.

image

haidelber commented 5 years ago

I try to do the same thing with the current yaml specification file from https://berlingroup.stackstorage.com/s/KeAqjlJmTNOmA1b and ran into an issue for the required fields in the components.headers section. Any ideas because the booleans seem resonable at this point of the specification? Thanks for the awesome tool by the way.

RicoSuter commented 4 years ago

The file is not available anymore. Is this issue still open?