jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.6k stars 4.03k forks source link

Jhipster swagger-ui not showing documentation #8842

Closed SameerNainawat closed 6 years ago

SameerNainawat commented 6 years ago

I have created a project using JHipster. API documentation is showing in v2/api-docs but it is showing nothing in swagger-ui/index.html

Jhispter swagger auto-configuration is not showing documentation and when I am adding swaggerConfiguration explicitly then it's throwing an exception of multiple dockers.

is there any way to fix it or any other way to bypass Jhipster swagger auto-configuration so that i can add it manually.

JHipster version 5.7.0

@deepu105 @jdubois @cbornet

jdubois commented 6 years ago

It totally depends on your configuration, please can you follow the guidelines and post your configuration?

SameerNainawat commented 6 years ago
jhipster:
    async:
        core-pool-size: 2
        max-pool-size: 50
        queue-capacity: 10000
    # By default CORS is disabled. Uncomment to enable.
    #cors:
        #allowed-origins: "*"
        #allowed-methods: "*"
        #allowed-headers: "*"
        #exposed-headers: "Authorization,Link,X-Total-Count"
        #allow-credentials: true
        #max-age: 1800
    mail:
        from: schoolmanagement@localhost
    swagger:
        default-include-pattern: /api/.*
        title: schoolmanagement API
        description: schoolmanagement API documentation
        version: 0.0.1
        terms-of-service-url:
        contact-name:
        contact-url:
        contact-email:
        license:
        license-url:

@jdubois

jdubois commented 6 years ago

No I mean your JHipster configuration, have a look at the template when creating a new issue, it's all explained. Basically we need the output of jhipster info

SameerNainawat commented 6 years ago

is that application.yml file? @jdubois

gmarziou commented 6 years ago

@SameerNainawat Julien asked you only to run jhipster info command in your project directory and paste its output here

SameerNainawat commented 6 years ago

$ jhipster info INFO! Using JHipster version installed globally INFO! Executing jhipster:info INFO! Options: from-cli: true Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
schoolmanagement@0.0.0 E:\Workspace Photon\schoolmanagement
`-- (empty)
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.schoolmanagement.system"
    },
    "jhipsterVersion": "5.0.1",
    "applicationType": "monolith",
    "baseName": "schoolmanagement",
    "packageName": "com.schoolmanagement.system",
    "packageFolder": "com/schoolmanagement/system",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "clientFramework": "angularX",
    "useSass": true,
    "clientPackageManager": "yarn",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": false
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

java version "1.8.0_181" Java(TM) SE Runtime Environment (build 1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

git version 2.16.1.windows.4

node: v10.13.0

npm: 6.4.1

yeoman: 2.0.5

INFO! Congratulations, JHipster execution is complete! @jdubois @gmarziou

PierreBesson commented 6 years ago

@SameerNainawat How are you running your app ? Dev mode with maven, prod from jar ? What are the active profiles ?

pascalgrimaud commented 6 years ago

Not enough information to reproduce.

I generated a project with old JHipster v5.0.1 -> the swagger-ui is well displayed. Same with the current version JHipster v5.7.0

If you find a real bug, plz give more information with all details steps to reproduce.

SameerNainawat commented 6 years ago

@PierreBesson I am running it in Dev mode with maven. and I am getting issue while jhipster runs npm install. image

pascalgrimaud commented 6 years ago

@SameerNainawat : I think the problem is with your environment, not with JHipster. See the logs: zlib: unexpected end of file. Some users suggest to use npm cache clean --force

Anyway, if you still encounter some issues with your machine, I suggest you to use our devbox

SameerNainawat commented 6 years ago

image image I have now clue why its not showing UI. @pascalgrimaud @jdubois @PierreBesson @gmarziou @deepu105

`##### JHipster Version(s)

schoolmanagement@0.0.0 E:\Workspace Photon\schoolmanagement
`-- (empty)
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.schoolmanagement.system"
    },
    "jhipsterVersion": "5.0.1",
    "applicationType": "monolith",
    "baseName": "schoolmanagement",
    "packageName": "com.schoolmanagement.system",
    "packageFolder": "com/schoolmanagement/system",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "clientFramework": "angularX",
    "useSass": true,
    "clientPackageManager": "yarn",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": false
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

java version "1.8.0_181" Java(TM) SE Runtime Environment (build 1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

git version 2.16.1.windows.4

node: v10.13.0

npm: 6.4.1

yeoman: 2.0.5 `

-------I have added registry in SecurityConfiguration---

  public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui/index.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
    }

------Added following in SwaggerConfig----------

      @Bean
    public Docket schoolApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select().apis(RequestHandlerSelectors.basePackage("com.schoolmanagement.system"))
                .paths(PathSelectors.any())
                .build();
                //.apiInfo(metaData()).securitySchemes(Lists.newArrayList(apiKey()));
    }
gmarziou commented 6 years ago

@SameerNainawat I understand that you want to know how to override JHipster's default swagger configuration but if you do it only because swagger-ui was not showing up I'm afraid that this is not the simplest way. First thing is to diagnose why it"s not working, once we understand we can make changes.

Otherwise, if you want to provide your own swagger configuration because you need to use extra features from springfox or to customize few things then you should try to exclude SwaggerAutoConfiguration class from autoconfiguration as you would do for any other Spring Boot autoconfiguration.

SameerNainawat commented 6 years ago

@gmarziou I don't want to bypass JHipster autoconfiguration, I just want to fix the bug in the same. When JHipster is providing default Swagger then why should I implement own swagger configuration? i have removed the own swagger configuration.

slaxminarayan commented 3 years ago

Hey @SameerNainawat can you please tell me how would you added swagger to your project. If possible please steps

PierreBesson commented 3 years ago

Please don't comment on an old issue. If you think this issue still applies, please create a new ticket with proper details.

If you have a question please use Stack Overflow, and tag the question with jhipster. This helps the project to keep the issue tracker clean. Also, Stack Overflow will give your question a larger audience: