oatpp / oatpp-swagger

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

Generate swagger definitions for Fields<T> #25

Closed natanael closed 4 years ago

natanael commented 4 years ago

We noticed there was no OAS definitions for Fields (e.g. Field for a simple case).

class UserDto : public oatpp::DTO {
  // [...]
  DTO_FIELD(Fields<String>, todoList);
  DTO_FIELD(Fields<Fields<String>>, todoTree);
  DTO_FIELD(Fields<Int64>, numberList);
  DTO_FIELD(Fields<Object<UserDto>>, friendsByNickname);
  DTO_FIELD(Fields<List<String>>, taskForFriends);
  // [...]
};

To generate something like:

{
  // [...]
  "todoList": {
    "type": "object",
    "additionalProperties": {
      "type": "string"
    }
  },
  "numberList": {
    "type": "object",
    "additionalProperties": {
      "type": "integer",
      "format": "int64"
    }
  },
  "friendsByNickname": {
    "type": "object",
    "additionalProperties": {
      "$ref": "#\/components\/schemas\/UserDto"
    }
  },
  "taskForFriends": {
    "type": "object",
    "additionalProperties": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "todoTree": {
    "type": "object",
    "additionalProperties": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    }
  }
  // [...]
}
lganzzzo commented 4 years ago

Great Work!!! And it's merged πŸŽ‰ πŸŽ‰ πŸŽ‰