Skip to content

[Typescript-Angular2] Generation of POST parameter with "array" schema causes Error. #6098

@savelievser

Description

@savelievser
Description

This problem appeared in v.2.2.3.
I'm trying to generate "typescript-angular2" client API with http://generator.swagger.io/#!/clients/generateClient service.
I cutted my configuration to make it more readable and it looks like this:

{
    "spec": {
        "swagger": "2.0",
        "info": {
            "version": "v1",
            "title": "Star.Web.Api"
        },
        "host": "localhost:5000",
        "schemes": ["http"],
        "paths": {
            "/api/notifications/read": {
                "put": {
                    "tags": ["Notifications"],
                    "summary": "Mark notifications as read",
                    "operationId": "Notifications_PutMultiRead",
                    "consumes": ["application/json", "text/json", "application/x-www-form-urlencoded"],
                    "produces": [],
                    "parameters": [{
                        "name": "ids",
                        "in": "body",
                        "description": "UID's of notifications",
                        "required": true,
                        "schema": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    }],
                    "responses": {
                        "204": {
                            "description": "No Content"
                        }
                    },
                    "security": [{
                        "oauth2": []
                    }]
                }
            }
        }
    },
    "options": {
        "modelPropertyNaming":"camelCase",
        "apiPackage":"app.webapi.api",
        "modelPackage":"app.webapi.model"
    }
}

Such a description leads to an error:

{
  "code": 1,
  "type": "error",
  "message": "Unable to build target: Could not generate api file for 'Notifications'"
}

That's because of the schema of my parameter:

"schema": {
    "type": "array",
    "items": {
        "type": "string"
    }
}

If I change it to object or to constant, everything OK. For example:

"schema": {
    "type": "string"
}

The Swagger spec say's that such a schema for parameter is absoluty legal:
https://swagger.io/specification/#parameterIn (see example where body parameter is an array of string values)

Swagger-codegen version

2.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions