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

[Bug] [INFO] save apiInfo failed:请求参数 data 应当有必需属性 api_type #1173

Open
1 task
chaosheng1991 opened this issue Nov 22, 2024 · 3 comments
Open
1 task
Labels
type: bug Something isn't working

Comments

@chaosheng1991
Copy link

Describe the bug

we install EasyYapi 2.7.3.212.0 in idea, choose controller api to export Yapi. The result shows "[INFO] save apiInfo failed:请求参数 data 应当有必需属性 api_type"

To Reproduce

Detailed Steps to reproduce the behavior:

  1. Open '...'
  2. Click on '....'
  3. See error

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Logs

  1. Add config:

    http.call.before=groovy:logger.info("call:"+request.url())
    http.call.after=groovy:logger.info("response:"+response.string())
    api.class.parse.before=groovy:logger.info("[api] before parse class:"+it)
    api.class.parse.after=groovy:logger.info("[api] after parse class:"+it)
    api.method.parse.before=groovy:logger.info("[api] before parse method:"+it)
    api.method.parse.after=groovy:logger.info("[api] after parse method:"+it)
    api.param.parse.before=groovy:logger.info("[api] before parse param:"+it)
    api.param.parse.after=groovy:logger.info("[api] after parse param:"+it)
    json.class.parse.before=groovy:logger.info("[json] before parse class:"+it)
    json.class.parse.after=groovy:logger.info("[json] after parse class:"+it)
    json.method.parse.before=groovy:logger.info("[json] before parse method:"+it)
    json.method.parse.after=groovy:logger.info("[json] after parse method:"+it)
    json.field.parse.before=groovy:logger.info("[json] before parse field:"+it)
    json.field.parse.after=groovy:logger.info("[json] after parse field:"+it)
  2. Console output easy_api

    • Please set Preferences(Settings) > Other Settings > EasyApi > Common > log to `LOW```
  3. Logs of IDEA:

    The easiest way to find the product log file is the Help menu, the item name would depend on the IDE version and OS:- Show Log in Explorer

    • Show Log in Finder
    • Show Log in Konqueror/Nautilus
    • Reveal Log in Explorer
    • Reveal Log in Finder/Finder/Nautilus

Environment (please complete the following information):

  • OS: [e.g. Windows]
  • IDEA version [e.g. 2021.2.3]
  • Plugin version [e.g. 2.2.9]
  • Yapi version [e.g. 1.9.1]

Demo Code

  1. Fork https://github.com/Earth-1610/spring-demo
  2. Write some code to reproduce this error
  3. Now paste the forked repository hear: https://github.com/xxxx/spring-demo

CheckList

  • Preferences(Settings) > Other Settings > EasyApi > Intelligent > enable infer

Additional context

Add any other context about the problem here.

@chaosheng1991 chaosheng1991 added the type: bug Something isn't working label Nov 22, 2024
@tangcent
Copy link
Owner

hi @chaosheng1991, as someone who also contributes to yapi, I have not come across a parameter called api_type anywhere. could you please confirm if you are using a customized or forked version of yapi? additionally, could you let me know what the possible values for api_type are?

if needed, you can use the rule http.call.before to populate the api_type field into the api data before submitting it to the yapi server. feel free to lmk if you need further assistance!

@chaosheng1991
Copy link
Author

hi @chaosheng1991, as someone who also contributes to yapi, I have not come across a parameter called api_type anywhere. could you please confirm if you are using a customized or forked version of yapi? additionally, could you let me know what the possible values for api_type are?

if needed, you can use the rule http.call.before to populate the api_type field into the api data before submitting it to the yapi server. feel free to lmk if you need further assistance!

Hi, I search the EasyYapi in idea Marketplace and install it, the version is 2.7.3.212.0. Then I config the server and token in idea, and use the function "Export Yapi" in controller, it shows this "save apiInfo failed:请求参数 data 应当有必需属性 api_type". But when I create the api in yapi system firstly, only name and path, then try it again. I find it it OK, and the params and response is added. Maybe all apis need I create them in yapi system firstly?

@tangcent
Copy link
Owner

@chaosheng1991 it seems that the yapi version you are using has been customized to require the api_type field when creating apis, but not when updating them. could you clarify the following for me?

  1. is the yapi you are using open source? if so, could you provide the repository URL?
  2. alternatively, can you let me know the possible values for the api_type field when creating an API?

with this information, I can try to identify if a customization is necessary based on the yapi response and implement a way to automatically populate the api_type field.

In the meantime, you can use the rule http.call.before to populate the api_type field into the api data before submitting it to the yapi server. For example:

http.call.before=groovy:```
request..body["api_type"] = 1
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants