Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
savelievser opened this issue Jul 18, 2017 · 4 comments

Comments

@savelievser
Copy link

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

@rgmills
Copy link

rgmills commented Jul 19, 2017

We're seeing the same thing after switching to 2.2.3. However, it's not limited to TypeScript-Angular, we can reproduce for TypeScript-fetch and csharp.

A similar gist for repo can be found - https://gist.github.com/rgmills/7dab54ab887adcf06968cb520cf4b2a9

@nailtonvieira
Copy link

nailtonvieira commented Jul 28, 2017

+1

name: id_product
------in: body
------description: Array of products id
------required: true
------schema:
-------type: array
-------items:
---------type: string

code: 1
type: "error"
message: "Unable to build target: Could not generate api file for 'Lists'"

@giansalex
Copy link

I have the same error

      parameters:
        - name: body
          in: body
          schema:
            type: array
            items:
              type: string

i cannot generate nothing:

Unable to build target: Could not generate api file for 'Consult'"

@Ellie-cpawar
Copy link

@ALL

Is this issue fixed or workaround available?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants