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

[Ada] wrong code generated when 2 properties point to same definition #7569

Closed
michelealbano opened this issue Feb 3, 2018 · 0 comments
Closed

Comments

@michelealbano
Copy link
Contributor

Description

When processing a YML file with a parameters that has two properties that refs to the same "definition (see YML file), the adb file for the model has got a wrong "Deserialize" method, which cannot be compiled. For example, with the YML below, it has a line saying:
Swagger.Streams.Deserialize (Object, "commands", Value.Commands);
that should be a:
Deserialize (Object, "commands", Value.Commands);

Swagger-codegen version

2.4.0-SNAPSHOT from the github

Swagger declaration file content or url
swagger: '2.0'
# edited with http://editor.swagger.io/
info:
  version: 1.0.0
  title: AH Orchestrator
  description: Service Interface for Arrowhead Orchestrator
  contact:
    name: Michele Albano
    email: mialb@isep.ipp.pt
    url: http://www.cister.isep.ipp.pt/people/michele_albano/
  license:
    name: MIT
    url: http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
host: 127.0.0.1:8442
basePath: "/orchestrator"
schemes:
  - http
consumes:
  - application/json
produces:
  - application/json


paths: 
  /orchestration:
    post:
      description: Query an orchestrated service instance
      operationId: orchStore
      parameters:
        - name: serviceRequestForm
          in: body
          description: Requests an orchestrated service instance
          required: true
          schema:
            type: object
            properties:
              requestedQoS:
                $ref: '#/definitions/stringsMap'
              commands:
                $ref: '#/definitions/stringsMap'
      responses:
        200:
          description: Response to a service orchestration request
        default:
          description: Unexpected error

definitions: 
  stringsMap:
    type: "object"
    properties:
      key:
        type: string
Command line used for generation

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i ../openapiAHproblem.yml -l ada -o ../ada-ah7/ --api-package AH.problem --model-package AH.problem

Steps to reproduce
  • generate the code
  • compile it (gprbuild -P defaultpackage.gpr)
Related issues/PRs

N/A

Suggest a fix/enhancement

Change how the model body (adb) is generated. In the example at hand, you generate a correct code for the "requestedQoS" property, but a wrong one for the "commands" property. Thus, instead of:

  Deserialize (Object, "requestedQoS", Value.Requested_Qo_S);
  Swagger.Streams.Deserialize (Object, "commands", Value.Commands);

please generate a:
Deserialize (Object, "requestedQoS", Value.Requested_Qo_S);
Deserialize (Object, "commands", Value.Commands);

@michelealbano michelealbano changed the title [Ada] [Ada] wrong code generated when 2 properties point to same definition Feb 5, 2018
wing328 pushed a commit that referenced this issue Feb 22, 2018
… the YML file (#7655)

* Ada generator generates "=>" (correct syntax) instead of "->". Fixes #7450

* Updated the Ada petstore samples

* Committing "VERSION" file and the rest of the petstore samples

* Changed default project name and package name for Ada, not to have circular dependencies between gpr files.

* Ada code generator now adds x-is-model-type every time a model is defined locally in the YML file.

Fix #7569.
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

1 participant