oatpp / oatpp-swagger

OpenApi 3.0.0 docs + Swagger UI for oatpp services
https://oatpp.io/
Apache License 2.0
91 stars 51 forks source link

DTO field description missing from "non-primitive" fields #29

Closed yeefan closed 3 years ago

yeefan commented 3 years ago

I am using Oat++ 1.1.0. Take the example-crud program, and modify the UserDto to become the following:

class UserDto : public oatpp::DTO {

  DTO_INIT(UserDto, DTO)

  DTO_FIELD_INFO(id) {
    info->description = "ID";
  }
  DTO_FIELD(Int32, id);

  DTO_FIELD_INFO(firstName) {
    info->description = "First name";
  }
  DTO_FIELD(String, firstName, "first-name");

  DTO_FIELD_INFO(lastName) {
    info->description = "Last name";
  }
  DTO_FIELD(String, lastName, "last-name");

  DTO_FIELD_INFO(friends) {
    info->description = "Friends";
  }
  DTO_FIELD(Vector<String>, friends) = Vector<String>({});

  DTO_FIELD_INFO(enemies) {
    info->description = "Enemies";
  }
  DTO_FIELD(List<String>, enemies) = List<String>({});

  DTO_FIELD_INFO(subUser) {
    info->description = "Sub user";
  }
  DTO_FIELD(Object<UserDto>, subUser, "sub-user");

};

Compile the program and run it. Go to the Swagger UI page and expand the schema for UserDto. I could see the field descriptions for id, first-name, and last-name, which are "primitive" fields. However, I cannot see the field descriptions for the friends, enemies, and sub-user, which are "non-primitive" fields containing a Vector, List, and another DTO respectively. Is this a bug? Thanks.

lganzzzo commented 3 years ago

Hey @yeefan ,

I've tested with your DTO, and I have descriptions (you just need to expand the item's details): (Tested with the latest commits from oatpp and oatpp-swagger)

Screenshot 2020-09-15 at 02 06 29 Screenshot 2020-09-15 at 02 06 41

Please let me know if it still doesn't work for you.

Regards, Leonid

yeefan commented 3 years ago

I'm sorry, I should have checked the master branch before filing this issue. Let me look at the master branch later. (Descriptions for "non-primitive" fields certainly aren't there in the 1.1.0 release.)

lganzzzo commented 3 years ago

No problem. You are right, these improvements were added after the 1.1.0 release

lganzzzo commented 3 years ago

Closing the issue...