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 order for generated structures in *-models.ads #7457

Closed
michelealbano opened this issue Jan 20, 2018 · 1 comment · Fixed by #7462
Closed

[Ada] wrong order for generated structures in *-models.ads #7457

michelealbano opened this issue Jan 20, 2018 · 1 comment · Fixed by #7462

Comments

@michelealbano
Copy link
Contributor

michelealbano commented Jan 20, 2018

Description

Generated code cannot be compiled, since:

" arrowhead-registry-models.ads:50:52: "Metadata_Type" not declared in "Models" "

Swagger-codegen version

2.3.1, downloaded from git on January 20, 2018

Swagger declaration file content or url

openapiAHregistrerShorter.yml:

swagger: '2.0'
# edited with http://editor.swagger.io/
info:
  version: 1.0.0
  title: AH Registry
  description: Service Interface for Arrowhead Registry
  termsOfService: http://helloreverb.com/terms/
  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: arrowhead.tmit.bme.hu
host: 127.0.0.1:8442
basePath: "/serviceregistry"
schemes:
  - https
  - http
consumes:
  - application/json
produces:
  - application/json


paths: 
  /register:
    post:
      description: Registers a service
      operationId: register
      parameters:
        - name: registerReqBody
          in: body
          description: Operation to register a service instance. All details must be specified for both the service, and its provider
          required: true
          schema:
            $ref: '#/definitions/serviceRegistryEntryType'
      responses:
        200:
          description: Data of the service that was registered
          schema:
            $ref: '#/definitions/serviceRegistryEntryType'
        default:
          description: Unexpected error

definitions: 
  metadata:
    type: "object"
    properties:
      entry:
        type: array
        items:
          type: object
          properties:
            key:
              type: string
            value:
              type: string
  serviceRegistryEntryType:
    type: object
    required:
# unique id
      - providedService
      - provider
# rest of stuff
      - UDP
      - serviceURI
      - version
    properties:
      providedService:
        $ref: '#/definitions/arrowheadServiceType'
      serviceURI:
        type: string
      version:
        type: integer
        format: int32
      isUDP:
        type: boolean
  arrowheadServiceType:
    type: object
    required:
# unique id
      - serviceGroup
      - serviceDefinition
# rest of stuff
      - interfaces
      - serviceMetadata
    properties:
      serviceGroup:
        type: string
      serviceDefinition:
        type: string
      interfaces:
        type: array
        items:
          type: string
      serviceMetadata:
        $ref: '#/definitions/metadata'
Command line used for generation

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i ../openapiAHregistrerShorter.yml -l ada -o ../ada-code/ --api-package Arrowhead.Registry --model-package Arrowhead.Registry

Steps to reproduce
  • generate the code (see previous point)
  • compile with gnat (make)
Related issues/PRs

N/A

Suggest a fix/enhancement

Revise ordering function "postProcessModels" in AbstractAdaCodegen.java

@stcarrez
Copy link
Contributor

Yes, the postProcessModels() operation sorts the model types depending on their dependencies.
The comparison function is not recursive so it ends up in wrong comparison when we have A -> B -> C the comparison between A, C are not well handled.

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

Successfully merging a pull request may close this issue.

2 participants