Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion examples/cosmo-cargo/schema/shipments.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
"name": "Cosmo Cargo API Support",
"email": "api@sh.example.com",
"url": "https://developers.sh.example.com"
}
},
"license": {
"name": "Apache"
},
"termsOfService": "https://example.com"
},
"externalDocs": {
"url": "https://example.com",
"description": "More documentation"
},
"x-tagGroups": [
{
Expand Down
21 changes: 21 additions & 0 deletions packages/zudoku/schema.graphql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const NavigationItem = ({
case "link":
case "custom-page": {
const href = item.type === "link" ? item.to : joinUrl(item.path);
const hasAnchor = href.includes("#");
return !href.startsWith("http") ? (
<AnchorLink
to={{
Expand All @@ -130,7 +131,9 @@ export const NavigationItem = ({
className={navigationListItem({
isActive:
href ===
[location.pathname, activeAnchor].filter(Boolean).join("#"),
(hasAnchor
? [location.pathname, activeAnchor].filter(Boolean).join("#")
: location.pathname),
})}
onClick={onRequestClose}
>
Expand Down
69 changes: 69 additions & 0 deletions packages/zudoku/src/lib/oas/graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from "@sindresorhus/slugify";
import { GraphQLJSON, GraphQLJSONObject } from "graphql-type-json";
import { createYoga, type YogaServerOptions } from "graphql-yoga";
import type { OpenAPIV3_1 } from "openapi-types";
import {
type EncodingObject,
type ExampleObject,
Expand Down Expand Up @@ -213,6 +214,35 @@ export const getAllOperations = (
return operations;
};

const SchemaContact = builder
.objectRef<OpenAPIV3_1.ContactObject>("SchemaContact")
.implement({
fields: (t) => ({
name: t.exposeString("name", { nullable: true }),
url: t.exposeString("url", { nullable: true }),
email: t.exposeString("email", { nullable: true }),
}),
});

const SchemaLicense = builder
.objectRef<OpenAPIV3_1.LicenseObject>("SchemaLicense")
.implement({
fields: (t) => ({
name: t.exposeString("name"),
url: t.exposeString("url", { nullable: true }),
identifier: t.exposeString("identifier", { nullable: true }),
}),
});

const SchemaExternalDocs = builder
.objectRef<OpenAPIV3_1.ExternalDocumentationObject>("SchemaExternalDocs")
.implement({
fields: (t) => ({
description: t.exposeString("description", { nullable: true }),
url: t.exposeString("url"),
}),
});

const SchemaTag = builder.objectRef<
Omit<TagObject, "name"> & { name?: string; slug?: string }
>("SchemaTag");
Expand Down Expand Up @@ -586,6 +616,45 @@ const Schema = builder.objectRef<OpenAPIDocument>("Schema").implement({
resolve: (root) => root.info.summary,
nullable: true,
}),
contact: t.field({
type: SchemaContact,
nullable: true,
resolve: (root) =>
root.info.contact != null
? {
name: root.info.contact.name,
url: root.info.contact.url,
email: root.info.contact.email,
}
: null,
}),
license: t.field({
nullable: true,
type: SchemaLicense,
resolve: (root) =>
root.info.license != null
? {
name: root.info.license.name,
url: root.info.license.url,
identifier: root.info.license.identifier,
}
: null,
}),
termsOfService: t.string({
resolve: (root) => root.info.termsOfService,
nullable: true,
}),
externalDocs: t.field({
nullable: true,
type: SchemaExternalDocs,
resolve: (root) =>
root.externalDocs != null
? {
description: root.externalDocs.description,
url: root.externalDocs.url,
}
: null,
}),
paths: t.field({
type: [PathItem],
resolve: (root) =>
Expand Down
Loading