Skip to content
This repository was archived by the owner on Aug 8, 2018. It is now read-only.

Model name is generated from description for body params and responses #76

@arabold

Description

@arabold

I must admit that I'm new to Swagger and AWS Gateway, but the following seems to be counter-intuitive. Please correct me if I'm doing something wrong or if I'm misunderstanding some core principles here.

I'm creating an API that returns a list of objects. For that reason I'm creating a definition like this:

get:
  summary: Genres
  responses:
    '200':
      description: Result
      schema:
        type: array
        items:
          $ref: Genre

The respective model definition looks like this:

Genre:
  type: object
  properties:
    genreId:
      type: string
    genreName: 
      type: string

Import works fine. However, the model created in AWS API Gateway is named "Result" now - it's based on the description of the response. Having multiple responses with the description "Result" will result in conflicts with only a single model being defined in the end. That can't be right, can it?

My expectation would be that I can define the name of the model, e.g. by specifying the "name" parameter.

I've identified the root cause of my problem in the ApiGatewaySdkSwaggerApiImporter.java as follows:

    String generateModelName(Response response) {
        return generateModelName(response.getDescription());
    }
    private String generateModelName(BodyParameter param) {
        return generateModelName(param.getDescription());
    }

For API responses as well as request bodys, the description property is used to generate the model name. However, for BodyParameter the property name seems more appropriate in my opinion. For Response I haven't found an obvious property such as name, but maybe a vendor extension would work.

Oh, and the most curious part is that the actual description field of the model in API Gateway (the one visible in the AWS console) is never set.

Any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions