Skip to content

Commit

Permalink
feat: Update Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cyaiox committed Nov 4, 2024
1 parent 25eaf01 commit 9e1e924
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
85 changes: 85 additions & 0 deletions src/entities/Map/schemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import schema from "decentraland-gatsby/dist/entities/Schema/schema"

import { realmSchema } from "../Place/schemas"

export const mapPlaceSchema = schema({
type: "object",
required: [],
patternProperties: {
"^-?\\d{1,3},-?\\d{1,3}$": {
type: "object",
required: [],
properties: {
id: {
type: "string",
format: "uudi",
description: "place id",
},
title: {
type: "string",
minLength: 0,
maxLength: 50,
description: "The place name",
},
description: {
type: "string",
minLength: 0,
maxLength: 5000,
description: "The place description",
},
image: {
description: "Url to the place cover or image",
type: "string",
format: "uri",
},
base_position: {
type: "string",
description: "The base position of the place",
pattern: "^-?\\d{1,3},-?\\d{1,3}$",
},
contact_name: {
type: "string",
minLength: 0,
maxLength: 5000,
description: "The contact name of the place",
},
user_like: {
type: "boolean",
description: "True if user likes the place",
},
user_dislike: {
type: "boolean",
description: "True if user dislikes the place",
},
user_favorite: {
type: "boolean",
description: "True if user seletect as favorite the place",
},
user_count: {
type: "number",
minimum: 0,
description: "The number of users in the place",
},
realms_detail: {
type: "array",
description:
"A list of realms with users in each Realm (experimental)",
items: realmSchema,
},
user_visits: {
type: "number",
minimum: 0,
description:
"The number of users that had visited the place in the last 30 days",
},
categories: {
type: "array",
description: "A list of the Place's categories",
items: { type: "string" },
},
},
},
},
})

export const mapPlaceResponseSchema = schema.api(mapPlaceSchema)
16 changes: 16 additions & 0 deletions src/pages/docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ApiDetails from "decentraland-gatsby/dist/components/Docs/ApiDetails"
import { Container } from "decentraland-ui/dist/components/Container/Container"

import Navigation from "../components/Layout/Navigation"
import { mapPlaceResponseSchema } from "../entities/Map/schemas"
import {
getPlaceListQuerySchema,
getPlaceParamsSchema,
Expand Down Expand Up @@ -110,6 +111,21 @@ export default function DocsPage() {
/>
<ApiDetails title="Response" body={worldListResponseSchema} />
</ApiCard>

<ApiCard
id="maps"
method="GET"
path="/api/map"
description="Returns an object with each Place's base position as the key"
>
<ApiDetails
title="Request"
cors="*"
query={getPlaceListQuerySchema}
/>
{/* TODO: Update ApiDetails component to render AJV patternProperties */}
<ApiDetails title="Response" body={mapPlaceResponseSchema} />
</ApiCard>
</Container>
</>
)
Expand Down

0 comments on commit 9e1e924

Please sign in to comment.