简体   繁体   中英

swagger-codegen simple models missing

I'm realizing my second API with swagger/swagger-codegen. After having a really good start with my first one I'm somewhat stuck with the following problem: I'm having multiple definitions like the following:

TopIssueReference:
  description: Id of a top issue
  type: string
  example:
    itemid: 'd32c1213-4773-442e-9c5f-f5d516358869'

All those definitions only are aliases for type string, some with format date-time, some naked like the one above.

The swagger editor is fine with those definitions.

When I use one of them in a $ref clause within some object definition the generator produces a reference to a class named like my definition, TopIssueReference in this case.

The generated TopIssueReference class is the following (in java):

@ApiModel(description = "Id of a top issue")
public class TopIssueReference  {
  @Override
  public String toString()  {
    StringBuilder sb = new StringBuilder();
    sb.append("class TopIssueReference {");
    sb.append("}");
    return sb.toString();
  }
}

which is not really useful.

Does anybody have an idea what's going wrong here? Shouldn't the generator either produce a reference to a String or at least make TopIssueReference derive from a string (however useful that may be)?

For some of those definitions, the generator does not generate any class at all - but the references are still there, so the resulting code does not even compile.

I tried generating servers and clients with java and python, and both are having the same problem.

Try Bellow code to your swagger file to generate code.

TopIssueReference:
    description: Id of a top issue
    type: object
    properties:
      itemid:
        type: string

i hope it's useful to you ...!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM