Code Monkey home page Code Monkey logo

Comments (7)

who avatar who commented on August 16, 2024 1

@Vidhyadharantechdays @Chort409 I have upgraded the example project to work with swagger-maven-plugin 3.1.0.

You may view it here: https://github.com/swagger-maven-plugin/swagger-maven-example

from swagger-maven-example.

Chort409 avatar Chort409 commented on August 16, 2024

It looks like the problem is not with the project but with swagger-maven-plugin. Downgraded its version to 3.0-M2-SNAPSHOT generated proper annotation

from swagger-maven-example.

vidhya03 avatar vidhya03 commented on August 16, 2024

Yes same for me i tried 3.1.0 , after downgraded to 3.0-M2-SNAPSHOT it is generated. I want to use latest 3.1.0 . In that case what should i do.?

from swagger-maven-example.

vidhya03 avatar vidhya03 commented on August 16, 2024

Verified it is working THanks @who Andrew

from swagger-maven-example.

trim09 avatar trim09 commented on August 16, 2024

This seems to be a fixed here: #14
I faced the same issue which was solved by applying the fix from mentioned pull request

from swagger-maven-example.

trungdoviet avatar trungdoviet commented on August 16, 2024

Thanks @who
With your link, it work (https://github.com/swagger-maven-plugin/swagger-maven-example)

I can summarize what have you changed on this new project.

1. update pom file:

  • use plugin swagger-maven-plugin with release version (you use 3.1.1 and i even can use 3.1.5).
  • In dependency section, change groupId of swagger-core from com.wordnik to io.swagger (use the original one)
  • Define security definition in apiSource like this:
<securityDefinitions>
                                <securityDefinition>
                                    <json>/securityDefinitions.json</json>
                                </securityDefinition>
                            </securityDefinitions> 

put file securityDefinitions.json to main/resources folder

2. Change import in source code: Scan all classes and change import from

com.wordnik.swagger.annotations.*; to io.swagger.annotations.*; AND com.wordnik.swagger.annotations.ApiResponse; to io.swagger.annotations.ApiResponse;
I see we need to change for package xxx.resource and xxx.model
You would see some incompatibilities from new import, so just fix following what maven tell you (ex: remove type attribute from annotation of apis (it's already declared on securityDefinition.json)

Do following those steps then i can make the original example run perfectly.
it also fix this one #16

Here is my new pom.xml

<xml version="1.0" encoding="UTF-8"? >
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>swagger-maven-example</groupId>
    <artifactId>swagger-maven-example</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>com.github.kongchen</groupId>
                <artifactId>swagger-maven-plugin</artifactId>
                <version>3.1.5</version>
                <configuration>
                    <apiSources>
                      <apiSource>
                            <springmvc>false</springmvc>
                            <locations>com.github.kongchen.swagger.sample.wordnik.resource</locations>
                            <schemes>http,https</schemes>
                            <host>petstore.swagger.wordnik.com</host>
                            <basePath>/api</basePath>
                            <info>
                                <title>Swagger Maven Plugin Sample</title>
                                <version>v1</version>
                                <description>This is a sample for swagger-maven-plugin</description>
                                <termsOfService>
                                    http://www.github.com/kongchen/swagger-maven-plugin
                                </termsOfService>
                                <contact>
                                    <email>[email protected]</email>
                                    <name>Kong Chen</name>
                                    <url>http://kongch.com</url>
                                </contact>
                                <license>
                                    <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                                    <name>Apache 2.0</name>
                                </license>
                            </info>
                            <!-- Support classpath or file absolute path here.
                            1) classpath e.g: "classpath:/markdown.hbs", "classpath:/templates/hello.html"
                            2) file e.g: "${basedir}/src/main/resources/markdown.hbs",
                                "${basedir}/src/main/resources/template/hello.html" -->
                            <templatePath>${basedir}/templates/strapdown.html.hbs</templatePath>
                            <outputPath>${basedir}/generated/document.html</outputPath>
                            <swaggerDirectory>generated/swagger-ui</swaggerDirectory>
							 <securityDefinitions>
                                <securityDefinition>
                                    <json>/securityDefinitions.json</json>
                                </securityDefinition>
                            </securityDefinitions>
                        </apiSource>
                    </apiSources>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-core</artifactId>
            <scope>compile</scope>
            <version>1.5.3</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.ws.rs</groupId>
                    <artifactId>jsr311-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback-version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>${logback-version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>${jersey2-version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-multipart</artifactId>
            <version>${jersey2-version}</version>
        </dependency>
    </dependencies>
    <properties>
        <jetty-version>9.0.7.v20131107</jetty-version>
        <jersey2-version>2.4.1</jersey2-version>
        <logback-version>1.0.1</logback-version>
    </properties>
    <pluginRepositories>
        <pluginRepository>
            <id>sonatype-snapshot</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</project>

Thanks a lot

from swagger-maven-example.

LuVsLu avatar LuVsLu commented on August 16, 2024

I have the same problems,my swagger-maven-plugin version is 1.3.5 , and I add the "method = RequestMethod.POST" on the annotation @RequestMapping, then it worked!

from swagger-maven-example.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.