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

[cpprest] Empty vendorExtension causes build error. #7572

Closed
p-groarke opened this issue Feb 4, 2018 · 3 comments
Closed

[cpprest] Empty vendorExtension causes build error. #7572

p-groarke opened this issue Feb 4, 2018 · 3 comments

Comments

@p-groarke
Copy link

Description

In api-source.mustache at line 384:

vendorExtensions.x-codegen-response.items.datatype

may be empty. Causes build error :

      no member named 'FromJson' in 'io::swagger::client::model::ModelBase'
            result = ModelBase::FromJson(json);

as that function doesn't exist.

API used to trigger error : https://esi.tech.ccp.is/latest/swagger.json

Swagger-codegen version

master

Swagger declaration file content or url

https://esi.tech.ccp.is/latest/swagger.json

Command line used for generation

java -jar swagger-codegen-cli.jar generate -i https://esi.tech.ccp.is/latest/swagger.json -l cpprest -o src

Steps to reproduce

Requires PR (to fix other build errors) : #7571

Related issues/PRs
Suggest a fix/enhancement

No suggestions yet.

@p-groarke p-groarke changed the title [cpprest] Missing vendorExtension causes build error. [cpprest] Empty vendorExtension causes build error. Feb 4, 2018
@p-groarke
Copy link
Author

This is the endpoint. My intuition points me to a float/double problem.

"/characters/{character_id}/cspa/": {
    "post": {
        "description": "Takes a source character ID in the url and a set of target character ID's in the body, returns a CSPA charge cost\n\n---\nAlternate route: `/dev/characters/{character_id}/cspa/`\n\nAlternate route: `/v4/characters/{character_id}/cspa/`\n",
        "summary": "Calculate a CSPA charge cost",
        "tags": [
            "Character"
        ],
        "parameters": [
            {
                "$ref": "#/parameters/character_id"
            },
            {
                "name": "characters",
                "in": "body",
                "description": "The target characters to calculate the charge for",
                "required": true,
                "schema": {
                    "type": "array",
                    "minItems": 1,
                    "uniqueItems": true,
                    "maxItems": 100,
                    "items": {
                        "type": "integer",
                        "format": "int32",
                        "title": "post_characters_character_id_cspa_character",
                        "description": "character integer"
                    },
                    "title": "post_characters_character_id_cspa_characters",
                    "description": "characters array"
                }
            },
            {
                "$ref": "#/parameters/datasource"
            },
            {
                "$ref": "#/parameters/token"
            },
            {
                "$ref": "#/parameters/user_agent"
            },
            {
                "$ref": "#/parameters/X-User-Agent"
            }
        ],
        "responses": {
            "201": {
                "description": "Aggregate cost of sending a mail from the source character to the target characters, in ISK",
                "examples": {
                    "application/json": 2950.0
                },
                "schema": {
                    "type": "number",
                    "format": "float",
                    "title": "post_characters_character_id_cspa_created",
                    "description": "201 created number"
                }
            },
            "403": {
                "description": "Forbidden",
                "schema": {
                    "$ref": "#/definitions/forbidden"
                },
                "examples": {
                    "application/json": {
                        "error": "Forbidden message"
                    }
                }
            },
            "500": {
                "description": "Internal server error",
                "schema": {
                    "$ref": "#/definitions/internal_server_error"
                },
                "examples": {
                    "application/json": {
                        "error": "Internal server error message"
                    }
                }
            }
        },
        "security": [
            {
                "evesso": [
                    "esi-characters.read_contacts.v1"
                ]
            }
        ],
        "operationId": "post_characters_character_id_cspa",
        "x-alternate-versions": [
            "dev",
            "v4"
        ]
    }
},

@p-groarke
Copy link
Author

Ok I've debugged this and have an answer, working on fix.

{{vendorExtensions.x-codegen-response.items.datatype}} assumes the primitive is contained in an item. The api I'm using returns the value itself. Changing to {{vendorExtensions.x-codegen-response.datatype}} fixes the issue.

@larsyxa
Copy link

larsyxa commented Jun 27, 2018

Usually generated code looks like this. Static FromJson does not exist. But specialized version do!!

double result(0.0);
if (responseHttpContentType == utility::conversions::to_string_t("application/json"))
{
web::json::value json = web::json::value::parse(response);
result = ModelBase::FromJson(json);
}

Change (in this case) result = ModelBase::FromJson(json) -> ModelBase::doubleFromJson(json);

Voila!

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

2 participants