oatpp / oatpp-swagger

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

Crashed when added doc controller #84

Closed AstroAir closed 11 months ago

AstroAir commented 1 year ago

Recently, I have been writing API documentation using oatpp swagger, but there have been some strange errors. After loading all the endpoints, I wrote router ->addController (oatpp:: swagger: AsyncController:: createShared (docEndpoints));, But at this point, it crashed directly without any error messages. I used gdb for debugging and found that the error occurred in oatpp swagger/Generator.cpp

oatpp::String Generator::getEnumSchemaName(const Type* type) {

  auto polymorphicDispatcher = static_cast<const data::mapping::type::__class::AbstractEnum::PolymorphicDispatcher*>(
    type->polymorphicDispatcher
  );

  Type* interType = polymorphicDispatcher->getInterpretationType(); // Segmentation fault

  data::stream::BufferOutputStream stream;
  stream << type->nameQualifier << "_" << interType->classId.name;
  return stream.toString();

}

This is the only error that can be queried, and when I delete router ->addController (oatpp:: swagger: AsyncController:: createShared (docEndpoints));, all code can run normally. I don't know where the problem occurred and I don't have any clue. Can you give me some help? Thank you!