Retrofit Mock Response

A library makes mock api from json files

Лицензия

Лицензия

Категории

Категории

Retrofit Сеть HTTP Clients
Группа

Группа

com.github.tientun
Идентификатор

Идентификатор

retrofit-mock-response
Последняя версия

Последняя версия

1.0.1
Дата

Дата

Тип

Тип

aar
Описание

Описание

Retrofit Mock Response
A library makes mock api from json files
Ссылка на сайт

Ссылка на сайт

https://github.com/tientun/Android-Retrofit-Mock-Response
Система контроля версий

Система контроля версий

https://github.com/tientun/Android-Retrofit-Mock-Response

Скачать retrofit-mock-response

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.tientun/retrofit-mock-response/ -->
<dependency>
    <groupId>com.github.tientun</groupId>
    <artifactId>retrofit-mock-response</artifactId>
    <version>1.0.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.tientun/retrofit-mock-response/
implementation 'com.github.tientun:retrofit-mock-response:1.0.1'
// https://jarcasting.com/artifacts/com.github.tientun/retrofit-mock-response/
implementation ("com.github.tientun:retrofit-mock-response:1.0.1")
'com.github.tientun:retrofit-mock-response:aar:1.0.1'
<dependency org="com.github.tientun" name="retrofit-mock-response" rev="1.0.1">
  <artifact name="retrofit-mock-response" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.tientun', module='retrofit-mock-response', version='1.0.1')
)
libraryDependencies += "com.github.tientun" % "retrofit-mock-response" % "1.0.1"
[com.github.tientun/retrofit-mock-response "1.0.1"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
com.squareup.retrofit2 : retrofit jar 2.1.0

Модули Проекта

Данный проект не имеет модулей.

#Retrofit mock response CircleCI Maven Central

##Features

  • Create fake response from json files
  • Support http methods

##Usage

1. Include library

Maven dependency:

<dependency>
	<groupId>com.github.tientun</groupId>
	<artifactId>retrofit-mock-response</artifactId>
	<version>1.0.0</version>
</dependency>

or

Gradle dependency:

compile 'com.github.tientun:retrofit-mock-response:1.0.0'

2. Retrofit client configs

Create OkHttpClient and add FakeInterceptor(context)

final OkHttpClient client = new OkHttpClient
                       .Builder()
                       .addInterceptor(new FakeInterceptor(context))
                       .build();

Create Retrofit with baseUrl("http://mock.api")

final Retrofit retrofit = new Retrofit.Builder()
                       .addConverterFactory(GsonConverterFactory.create())
                       .baseUrl("http://mock.api")
                       .client(client)
                       .build();

3. Create asset folder "mock.api" debug type

src/debug/assets/mock.api/
                        api1/
                        api2/
                        api3/
                            index.json
                            getUsers.json
                            user.json
                            ...

License

Copyright 2016 Tien Hoang

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.

Версии библиотеки

Версия
1.0.1
1.0.0