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

additionalProperties using ref to file does not generate correctly #4688

Open
JLLeitschuh opened this issue Jan 31, 2017 · 1 comment
Open

Comments

@JLLeitschuh
Copy link
Contributor

Description

Generating a map type in swagger where additionalProperties references a file results in the resulting simplified swagger file being wrong:

Result of the yaml generator

definitions:
  FabricControllerMap:
    type: "object"
    additionalProperties:
      $ref: "./definitions/FabricController.yaml#/FabricController"
  FabricController:
    allOf:
    - $ref: "#/definitions/PlexxiObject"
    - properties:
        apiVersion:
          type: "string"
        connectionFailedCount:
          type: "integer"
          format: "int64"
          readOnly: true
        # Ect.....

Result of the spring code generator

/**
 * FabricControllerMap
 */
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2017-01-31T13:48:25.402-05:00")

public class FabricControllerMap extends HashMap<String, DefinitionsFabricControllerYamlFabricController>  {
    // ....
Swagger-codegen version

Latest master

Swagger declaration file content or url

./definitions/FabricController.yaml

FabricController:
  type: object
  description: |
    The abstract representation of all types of Ports.
  allOf:
  - $ref: './definitions/PlexxiObject.yaml#/PlexxiObject'
  - properties:
      apiVersion:
        type: string
      connectionFailedCount:
        type: integer
        format: int64
        readOnly: true
     # ect.....

./definitions/FabricControllerMap.yaml

FabricControllerMap:
  type: object
  additionalProperties:
    $ref: './definitions/FabricController.yaml#/FabricController'

./swagger.yaml

# More above
parameters:
  FabricControllerListBody:
    name: fabricController
    in: body
    required: true
    schema:
      type: array
      items:
        $ref: './definitions/FabricControllerMap.yaml#/FabricControllerMap'
Command line used for generation

lang = "io.swagger.codegen.languages.SwaggerYamlGenerator"

Steps to reproduce

Try to create a map that makes reference to a type declared in a different file.

Related issues
Suggest a Fix

Whatever type resolution for $ref that happens on properties in objects needs to also happen in additionalProperties.

@wing328
Copy link
Contributor

wing328 commented Feb 2, 2017

@JLLeitschuh I think that's a limitation with Swagger Parser at the moment. A workaround is to define the reference within the same file for the time being.

cc @fehguy

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

No branches or pull requests

2 participants