Features | Download | Who Made This | Contribute | Bugs and Feedback | License
Include the jcenter repository in your top build.gradle
:
Enabled by default on AndroidStudio projects
allprojects {
jcenter()
}
It requires kapt in order to make it run. You need to add this line on the build.gradle of the module where you want use it.
apply plugin: "kotlin-kapt"
kapt "com.adevinta.spain:retroswagger:1.0.0"
annotationProcessor "com.adevinta.spain:retroswagger:1.0.0"
implementation "com.adevinta.spain:retroswagger:1.0.0"
In order for your project recognizes the generated code you will need to include it into your sources path, like this:
android {
...
sourceSets {
main.java.srcDirs += "${buildDir.absolutePath}/tmp/kapt3/incrementalData/debug/path/to/your/generated/code"
}
...
}
You can use your own file creator or use the annotation comes with the library that generates the files for you. On the class you want to include the generated code you need to add this annotation "@Retroswagger()".
@Retroswagger(
"Swagger URL",
"Name of the api interface you want to have",
"Cache policy in Days",
"Remove trailing slash on the interface methods")
class MyClass() {
}
Trailing slash example:
@GET("pet/findByStatus")
@GET("/pet/findByStatus")
Example:
@Retroswagger("http://petstore.swagger.io/v2/swagger.json", "PetStore", 1, true)
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
You need to take into account that this will generate all the files on the same package you include this annotation. For example, if you include it on the class "MyActivity" that is on the package "com.company.mymodule.myfeature.views" it will assign the package for all the generated files to this package.
If you are using it on an Android project and you use Proguard, you will need to add this proguard rules:
-dontwarn org.yaml.snakeyaml.**
-dontwarn org.slf4j.**
-dontwarn io.swagger.**
-dontwarn com.google.common.**
-dontwarn com.google.auto.**
-dontwarn javax.xml.datatype.**
-dontwarn com.fasterxml.jackson.**
-dontwarn com.squareup.kotlinpoet.**
-dontwarn com.adevinta.spain.**
Beware, if you are using one of these package maybe one or more of these rule will not be needed. Also, it's possible that you will need to add more rules.
If you are using using a test framework it will be needed to add a explicit dependency in order to use it on your tests
androidTestAnnotationProcessor "com.adevinta.spain:retroswagger:1.0.0"
Ferran Pons |
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)For bugs, questions and discussions please use the Github Issues.
Copyright 2019 Schibsted Classified Media Spain S.L.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.