cstroe / swagger-ant-task

An ant task that generates swagger JSON spec files from Java code.
Apache License 2.0
3 stars 3 forks source link

Packages not found if source code isn't in src/main/java #2

Open Jeevi21 opened 8 years ago

Jeevi21 commented 8 years ago

This is my apisource

     <apiSource>                
                <locations>appstore.partner.rest.resources</locations>
                <apiVersion>v1</apiVersion>
                <host>http://slczff.us.com:701/</host>
                <basePath>/myapis</basePath>
                <info>
                    <title>Swagger Maven Plugin Sample</title>
                    <version>v1</version>
                    <description>My sample</description>
                    <termsOfService>TermsOfService</termsOfService>
                    <contact>
                        <email>api@gmail.com</email>
                        <name>My Apis</name>
                        <url>http://apis.com</url>
                    </contact>
                    <license>
                        <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                        <name>Apache 2.0</name>
                    </license>
                </info>

                 <!---Swagger JSON parameters BEGIN-->
                <swaggerDirectory>generated/swagger-ui</swaggerDirectory>                    
                <useOutputFlatStructure>false</useOutputFlatStructure>
                <!---Swagger JSON parameters END-->
     </apiSource>

location - is the package which needs to be scanned. Swagger.json is getting generated. But details about my api's are not included in json. can anyone help me in getting it right? Thanks, Jeevi N

cstroe commented 8 years ago

Reading the documentation of swagger-maven-plugin, it seems you're specifying the locations tag incorrectly. It should be like this:

<locations>
    <location>oracle.cloud.appstore.partner.rest.resources</location>
</locations>

Please make the correction to your configuration and try again. If this fixes the issue, please close the issue.

Jeevi21 commented 8 years ago

Hi i tried your solution. But its not working... I got the below error.

  bash-4.1$ ant -file build_swagger.xml
  Buildfile: build_swagger.xml
  swaggertask.init:
  swaggertask.first:
  BUILD FAILED
  build_swagger.xml:59: locations doesn't support the nested "location" element.
cstroe commented 8 years ago

I will have to investigate this further.

Jeevi21 commented 8 years ago

My resource files are not under /src/main/java... I think that s the problem.. Is there any way to give customized src path?

cstroe commented 7 years ago

@Jeevi21 The path where your source files are located is a Maven configuration in your pom.xml:

...
<build>
    <sourceDirectory>path/to/src</sourceDirectory>
    ...
</build>
...

But since this is an Ant task that's wrapping a Maven plugin, there's a disconnect there, and I didn't take care of that special case.

Would you be interested in working on this?