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

[Java]Missing classes when generating code #8364

Open
bogdan-pistol opened this issue Jun 28, 2018 · 2 comments
Open

[Java]Missing classes when generating code #8364

bogdan-pistol opened this issue Jun 28, 2018 · 2 comments

Comments

@bogdan-pistol
Copy link

bogdan-pistol commented Jun 28, 2018

Description

I am trying to generate Java client classes. I am using the following plugin config:

            <plugin>
                <groupId>io.swagger</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>2.3.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/src/main/resources/swagger-api-v1.json</inputSpec>
                            <language>spring</language>
                            <library>spring-cloud</library>
                            <output>${project.build.directory}/generated-sources</output>
                            <apiPackage>${default.package}.handler</apiPackage>
                            <modelPackage>${default.package}.model</modelPackage>
                            <invokerPackage>${default.package}.handler</invokerPackage>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

The specfile specifies OAuth2.

   "securityDefinitions": {
    "app-developer": {
      "type": "oauth2",
      "flow": "application",
      "tokenUrl": "https://api.myApp.com/oauth/v2/token",
      "scopes": {
        "crs": "App Services"
      }
    }
  },
  "security": [
    {
      "app-developer": [
        "crs"
      ]
    }
  ],

When i run mvn package i get:

[ERROR] /C:/work/djingo/repos/skill-recipe-java/target/generated-sources/src/main/java/io/swagger/configuration/ClientConfiguration.java:[11,62] package org.springframework.cloud.security.oauth2.client.feign does not exist
[ERROR] /C:/work/djingo/repos/skill-recipe-java/target/generated-sources/src/main/java/io/swagger/configuration/ClientConfiguration.java:[12,50] package org.springframework.security.oauth2.client does not exist
[ERROR] /C:/work/djingo/repos/skill-recipe-java/target/generated-sources/src/main/java/io/swagger/configuration/ClientConfiguration.java:[13,59] package org.springframework.security.oauth2.client.resource does not exist
[ERROR] /C:/work/djingo/repos/skill-recipe-java/target/generated-sources/src/main/java/io/swagger/configuration/ClientConfiguration.java:[14,69] package org.springframework.security.oauth2.client.token.grant.client does not exist
[ERROR] /C:/work/djingo/repos/skill-recipe-java/target/generated-sources/src/main/java/io/swagger/configuration/ClientConfiguration.java:[15,67] package org.springframework.security.oauth2.client.token.grant.code does not exist
[ERROR] /C:/work/djingo/repos/skill-recipe-java/target/generated-sources/src/main/java/io/swagger/configuration/ClientConfiguration.java:[16,71] package org.springframework.security.oauth2.client.token.grant.implicit does not exist
[ERROR] /C:/work/djingo/repos/skill-recipe-java/target/generated-sources/src/main/java/io/swagger/configuration/ClientConfiguration.java:[17,71] package org.springframework.security.oauth2.client.token.grant.password does not exist
[ERROR] /C:/work/djingo/repos/skill-recipe-java/target/generated-sources/src/main/java/io/swagger/configuration/ClientConfiguration.java:[18,61] package org.springframework.security.oauth2.common.exceptions does not exist
[ERROR] /C:/work/djingo/repos/skill-recipe-java/target/generated-sources/src/main/java/io/swagger/configuration/ClientConfiguration.java:[19,61] package org.springframework.security.oauth2.common.exceptions does not exist

I suppose I need to add some Spring OAuth2 dependencies but i couldn't find it documented anywhere.

Swagger-codegen version

2.3.1

@tazzer512
Copy link

just add the missing dependencies to your pom, like:

<dependencies>
    <dependency>
      <groupId>org.springframework.security.oauth</groupId>
      <artifactId>spring-security-oauth2</artifactId>
     <version>2.0.3.RELEASE</version>
     </dependency>
</dependencies>

@johnaoss
Copy link

johnaoss commented Jul 26, 2018

@bogdan-pistol can you please post your generated pom.xml?

I had a similar issue on compile, but it was resolved in-IDE when I imported my generated files as a Maven module.

I'm assuming there's a way to specify Maven to recognize this as a module, but I'm not too sure of a way at this moment.

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

No branches or pull requests

3 participants