Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The errorCodeDictionaries enumeration class does not exist; getter method results in an error. #408

Closed
Ikki-Dai opened this issue Jan 9, 2023 · 6 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Ikki-Dai
Copy link

Ikki-Dai commented Jan 9, 2023

Your Environment(您的使用环境)

  • smart-doc version: latest
  • plugin version (e.g. smart-doc-maven-plugin or smart-doc-gradle-plugin): 2.6.3
  • build tool version(maven or gradle): maven

Expected Behavior(您期望的结果)

errorCodeDictionaries: [{
"title": "http code",
"enumClassName": "org.springframework.http.HttpStatus",
"codeField": "value",
"descField": "reasonPhrase"
}]

Current Behavior(当前结果)

java.lang.NoSuchMethodException: org.springframework.http.HttpStatus.getValue()

Possible Solution(bug解决建议)

Enums may not have getter methods corresponding to their fields.
Enum 可能不存在字段对应的 getter 方法

Steps to Reproduce (Bug产生步骤,请尽量提供用例代码)

Context(Bug影响描述)

When designing an interface using RESTful,
it is not possible to use Spring HTTP status as the response code for outputting documentation.

@Ikki-Dai Ikki-Dai added the bug Something isn't working label Jan 9, 2023
@Ikki-Dai
Copy link
Author

Ikki-Dai commented Jan 9, 2023

Configuring the internal enumeration org.eclipse.jetty.http.HttpStatus.Code also fails to resolve: ClassNotFoundException is thrown.
配置 org.eclipse.jetty.http.HttpStatus.Code 内部枚举,也无法解析:ClassNotFoundException

@netdied
Copy link
Collaborator

netdied commented Jan 9, 2023

Business enumerations are generally defined by oneself, aren't they? What scenarios require the use of the HttpStatus enumeration class? Here, enumeration values are obtained through the reflection of getter methods; if a getter method cannot be found, the enumeration class cannot be parsed.
业务枚举一般不是自己定义嘛?是什么场景需要使用HttpStatus枚举类呢?这里是通过反射getter方法获取枚举值,如果找不到getter方法都无法对枚举类进行解析。

@Ikki-Dai
Copy link
Author

Ikki-Dai commented Jan 9, 2023

The API is designed according to standard RESTful principles, using HTTP status.
API 按照标准restful 设计的,使用的http status

@shalousun
Copy link
Collaborator

shalousun commented Jan 10, 2023

@Ikki-Dai Upon reviewing the code, it seems that the issue actually stems from the Spring source code; some fields have getters added while others do not, resulting in an inconsistent style.

@Ikki-Dai
Copy link
Author

Ikki-Dai commented Jan 10, 2023

Let's see if we can support parsing methods for codeField and descField; if they end with () then execute the corresponding method.
看看能不能把 codeFielddescField 支持解析方法,如果是() 结尾就执行对应的方法

@shalousun shalousun added this to the 2.6.4 milestone Jan 11, 2023
shalousun added a commit to shalousun/ApplicationPower that referenced this issue Jan 11, 2023
@shalousun shalousun self-assigned this Jan 11, 2023
@shalousun
Copy link
Collaborator

shalousun commented Jan 11, 2023

Let's see if we can support parsing methods for codeField and descField; if they end with () then execute the corresponding method.
看看能不能把 codeFielddescField 支持解析方法,如果是() 结尾就执行对应的方法

This can also be the configuration with the least changes.
可以这个也是配置改变最小的了

shalousun added a commit to smart-doc-group/smart-doc-group.github.io that referenced this issue Jan 11, 2023
@shalousun shalousun changed the title errorCodeDictionaries 枚举类不存在 getter 方法报错 The errorCodeDictionaries enumeration class does not exist; getter method results in an error. Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants