jsonPlaceholder static method
Creates a sample JSONPlaceholder API definition using the simple builder.
Implementation
static ApiDefinition jsonPlaceholder() {
return SimpleApiBuilder(
title: 'JSONPlaceholder API',
baseUrl: 'https://jsonplaceholder.typicode.com',
description: 'Fake online REST API for testing and prototyping',
)
.get('/posts',
name: 'Get All Posts',
description: 'Retrieve all posts',
queryParams: ['userId', '_limit', '_start'],
tags: ['posts', 'read'],
responseType: 'List<Post>')
.get('/posts/{id}',
name: 'Get Post by ID',
description: 'Retrieve a specific post',
tags: ['posts', 'read'],
responseType: 'Post')
.post('/posts',
name: 'Create Post',
description: 'Create a new post',
tags: ['posts', 'write'],
responseType: 'Post')
.put('/posts/{id}',
name: 'Update Post',
description: 'Update an existing post',
tags: ['posts', 'write'],
responseType: 'Post')
.delete('/posts/{id}',
name: 'Delete Post',
description: 'Delete a post',
tags: ['posts', 'write'],
responseType: 'void')
.get('/users',
name: 'Get All Users',
description: 'Retrieve all users',
tags: ['users', 'read'],
responseType: 'List<User>')
.get('/users/{id}',
name: 'Get User by ID',
description: 'Retrieve a specific user',
tags: ['users', 'read'],
responseType: 'User')
.get('/comments',
name: 'Get Comments',
description: 'Retrieve comments',
queryParams: ['postId', '_limit'],
tags: ['comments', 'read'],
responseType: 'List<Comment>')
.build();
}