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

Swagger UI - management API - GET requests with body #12412

Closed
ndywicki opened this issue Sep 8, 2020 · 5 comments
Closed

Swagger UI - management API - GET requests with body #12412

ndywicki opened this issue Sep 8, 2020 · 5 comments

Comments

@ndywicki
Copy link
Contributor

ndywicki commented Sep 8, 2020

Overview of the issue

Hello Team,

When I try to fetch the Spring Boot Actuator APIs (/management) with Swagger UI, there is an issue about the GET request have a body.

Stacktrace:

swagger-ui-bundle.js:6 TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.
    at swagger-ui-bundle.js:6
    at c (swagger-ui-bundle.js:79)
    at Generator._invoke (swagger-ui-bundle.js:79)
    at Generator.e.<computed> [as next] (swagger-ui-bundle.js:79)
    at o (swagger-ui-bundle.js:51)
    at s (swagger-ui-bundle.js:51)

I'm not sure where come from the Open API specifications : http://localhost:8080/v2/api-docs?group=management but the GET request have a parameter in "Body" like "additionalProp1, ..."

Example:
Swagger-UI-get-issue

Motivation for or Use Case
Reproduce the error

Generate new Jhipster application with all default values.
After admin login go to API menu and try management API with GET requests.

Related issues

No found in Jhipster but maybe this https://stackoverflow.com/questions/48749252/swagger-typeerror-failed-to-execute-fetch-on-window-request-with-get-head ?

Suggest a Fix
JHipster Version(s)

v6.9.0
v6.10.1

JHipster configuration

Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
sampleapp@0.0.1-SNAPSHOT C:\Workspaces\jhipster\v6.10.1\sampleapp
`-- generator-jhipster@6.10.1

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.mycompany.myapp",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "6.10.1",
    "applicationType": "monolith",
    "baseName": "sampleapp",
    "packageName": "com.mycompany.myapp",
    "packageFolder": "com/mycompany/myapp",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "caffeine",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "postgresql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "angularX",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1599569444230,
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": ["en", "fr"],
    "blueprints": []
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-b01)
Eclipse OpenJ9 VM (build openj9-0.21.0, JRE 1.8.0 Windows 10 amd64-64-Bit Compressed References 20200728_776 (JIT enabled, AOT enabled)
OpenJ9 - 34cf4c075
OMR - 113e54219
JCL - c82ff0c20f based on jdk8u265-b01)

git version 2.28.0.windows.1

node: v14.8.0

npm: 6.14.7

Docker version 19.03.12, build 48a66213fe

docker-compose version 1.26.2, build eefe0d31

INFO! Congratulations, JHipster execution is complete!

Browsers and Operating System

Win10 & Edge Version 85.0.564.44 (Version officielle) (64 bits)

@pascalgrimaud
Copy link
Member

thanks for reporting this @ndywicki
I already saw this issue too, but not sure we can do something, as the API comes from Spring Boot

@github-actions
Copy link
Contributor

This issue is stale because it has been open 30 days with no activity.
Our core developers tend to be more verbose on denying. If there is no negative comment, possibly this feature will be accepted.
We are accepting PRs 😃.
Comment or this will be closed in 7 days

@PierreBesson
Copy link
Contributor

PierreBesson commented Nov 1, 2020

I confirm this issue which is quite annoying. This is 100% caused by Swagger UI itself which fills out the request body with this sample text: {"additionalProp1":"string","additionalProp2":"string","additionalProp3":"string"}. I think I can find a workaround.

PierreBesson added a commit to PierreBesson/generator-jhipster that referenced this issue Nov 1, 2020
PierreBesson added a commit to PierreBesson/generator-jhipster that referenced this issue Nov 1, 2020
pascalgrimaud added a commit that referenced this issue Nov 9, 2020
…gement-default-body

remove the sample Swagger UI request body if present fix #12412
PierreBesson added a commit to PierreBesson/jhipster-control-center that referenced this issue Dec 6, 2020
@pascalgrimaud pascalgrimaud added this to the 7.0.0-beta.0 milestone Dec 18, 2020
@pascalgrimaud pascalgrimaud reopened this Jan 11, 2022
@ndywicki
Copy link
Contributor Author

ndywicki commented Mar 3, 2022

Hello,

Just for information is the same on the Jhipster-lite (v0.0.12-SNAPSHOT) Swagger UI ;-)
But strangely no fetch error, only the badly interpreted the ProjectDTO schema:

Capture

Could be a clue

@pascalgrimaud
Copy link
Member

Yes it's normal, as the swagger ui here is managed only by the backend, so no manual fix has been applied :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants