-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from Automattic/hamorillo/65-openapi-generation
SDK - APIs code generation based on OpenApi definition
- Loading branch information
Showing
28 changed files
with
788 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,12 +45,12 @@ import com.gravatar.DefaultAvatarImage | |
import com.gravatar.GravatarApi | ||
import com.gravatar.ImageRating | ||
import com.gravatar.R | ||
import com.gravatar.api.models.UserProfiles | ||
import com.gravatar.demoapp.theme.GravatarDemoAppTheme | ||
import com.gravatar.demoapp.ui.components.GravatarEmailInput | ||
import com.gravatar.demoapp.ui.components.ProfileCard | ||
import com.gravatar.demoapp.ui.model.SettingsState | ||
import com.gravatar.emailAddressToGravatarUrl | ||
import com.gravatar.models.UserProfiles | ||
import com.gravatar.sha256Hash | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.launch | ||
|
@@ -146,7 +146,7 @@ private fun GravatarTabs( | |
private fun ProfileTab(modifier: Modifier = Modifier, onError: (String?, Throwable?) -> Unit) { | ||
var email by remember { mutableStateOf("[email protected]", neverEqualPolicy()) } | ||
var hash by remember { mutableStateOf("", neverEqualPolicy()) } | ||
var profiles by remember { mutableStateOf(UserProfiles(), neverEqualPolicy()) } | ||
var profiles by remember { mutableStateOf(UserProfiles(emptyList()), neverEqualPolicy()) } | ||
var loading by remember { mutableStateOf(false) } | ||
var error by remember { mutableStateOf("") } | ||
val gravatarApi = GravatarApi() | ||
|
@@ -195,7 +195,7 @@ private fun ProfileTab(modifier: Modifier = Modifier, onError: (String?, Throwab | |
} | ||
} | ||
// Show the profile card if we got a result and there is no error and it's not loading | ||
if (!loading && error.isEmpty() && profiles.entry.size > 0) { | ||
if (!loading && error.isEmpty() && profiles.entry.isNotEmpty()) { | ||
ProfileCard( | ||
profiles.entry.first(), | ||
Modifier | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
openapi: "3.1.0" | ||
info: | ||
version: 1.0.0 | ||
title: Gravatar | ||
servers: | ||
- url: https://www.gravatar.com | ||
paths: | ||
/{hash}.json: | ||
get: | ||
summary: Profile for a specific hash | ||
operationId: getProfile | ||
tags: | ||
- profile | ||
parameters: | ||
- name: hash | ||
in: path | ||
required: true | ||
description: The email's hash of the profile to retrieve. | ||
schema: | ||
type: string | ||
responses: | ||
'200': | ||
description: Expected response to a valid request | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/UserProfiles" | ||
default: | ||
description: unexpected error | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Error" | ||
components: | ||
schemas: | ||
UserProfiles: | ||
type: object | ||
required: | ||
- entry | ||
properties: | ||
entry: | ||
type: array | ||
default: [] | ||
items: | ||
$ref: "#/components/schemas/UserProfile" | ||
UserProfile: | ||
type: object | ||
required: | ||
- hash | ||
properties: | ||
hash: | ||
description: The email's hash of the profile. | ||
type: string | ||
requestHash: | ||
type: string | ||
profileUrl: | ||
type: string | ||
format: url | ||
preferredUsername: | ||
type: string | ||
thumbnailUrl: | ||
type: string | ||
format: url | ||
last_profile_edit: | ||
type: string | ||
profileBackground: | ||
$ref: "#/components/schemas/ProfileBackground" | ||
name: | ||
$ref: "#/components/schemas/Name" | ||
displayName: | ||
type: string | ||
pronouns: | ||
type: string | ||
aboutMe: | ||
type: string | ||
currentLocation: | ||
type: string | ||
share_flags: | ||
$ref: "#/components/schemas/ShareFlags" | ||
emails: | ||
type: array | ||
items: | ||
$ref: "#/components/schemas/Email" | ||
Name: | ||
type: object | ||
required: | ||
- givenName | ||
- familyName | ||
- formatted | ||
properties: | ||
givenName: | ||
type: string | ||
familyName: | ||
type: string | ||
formatted: | ||
type: string | ||
ShareFlags: | ||
type: object | ||
required: | ||
- search_engines | ||
properties: | ||
search_engines: | ||
type: boolean | ||
ProfileBackground: | ||
type: object | ||
required: | ||
- color | ||
- url | ||
properties: | ||
color: | ||
type: string | ||
url: | ||
type: string | ||
format: url | ||
Email: | ||
type: object | ||
properties: | ||
primary: | ||
type: boolean | ||
value: | ||
type: string | ||
Error: | ||
type: object | ||
required: | ||
- code | ||
- message | ||
properties: | ||
code: | ||
type: integer | ||
format: int32 | ||
message: | ||
type: string |
Oops, something went wrong.