From abd213cd488a512fc2da78fc209f25cbf235ae41 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Fri, 26 Jan 2024 09:09:39 -0800 Subject: [PATCH] Shorten homepage examples (#2830) image --- .changeset/gorgeous-spiders-crash.md | 31 ---------- .changeset/perfect-masks-jam.md | 2 + package.json | 1 + .../hero-illustration.module.css | 2 +- .../hero-illustration/hero-illustration.tsx | 8 +-- .../tsp-samples/homepage/hero/http/main.tsp | 19 ++++++ .../homepage/hero/http/out/openapi.yaml | 62 +++++++++++++++++++ .../homepage/hero/http/tspconfig.yaml | 4 ++ .../homepage/hero/json-schema/main.tsp | 25 ++++++++ .../homepage/hero/json-schema/out/schema.yaml | 60 ++++++++++++++++++ .../homepage/hero/json-schema/tspconfig.yaml | 5 ++ .../openapi3/hero/out/openapi.yaml | 10 +-- 12 files changed, 184 insertions(+), 45 deletions(-) delete mode 100644 .changeset/gorgeous-spiders-crash.md create mode 100644 .changeset/perfect-masks-jam.md create mode 100644 packages/website/static/tsp-samples/homepage/hero/http/main.tsp create mode 100644 packages/website/static/tsp-samples/homepage/hero/http/out/openapi.yaml create mode 100644 packages/website/static/tsp-samples/homepage/hero/http/tspconfig.yaml create mode 100644 packages/website/static/tsp-samples/homepage/hero/json-schema/main.tsp create mode 100644 packages/website/static/tsp-samples/homepage/hero/json-schema/out/schema.yaml create mode 100644 packages/website/static/tsp-samples/homepage/hero/json-schema/tspconfig.yaml diff --git a/.changeset/gorgeous-spiders-crash.md b/.changeset/gorgeous-spiders-crash.md deleted file mode 100644 index 8a02cf76a..000000000 --- a/.changeset/gorgeous-spiders-crash.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -"@typespec/prettier-plugin-typespec": patch -"@typespec/eslint-config-typespec": patch -"@typespec/eslint-plugin": patch -"@typespec/internal-build-utils": patch -"tmlanguage-generator": patch -"@typespec/html-program-viewer": patch -"@typespec/playground-website": patch -"@typespec/bundle-uploader": patch -"typespec-vscode": patch -"@typespec/best-practices": patch -"@typespec/library-linter": patch -"@typespec/json-schema": patch -"typespec-vs": patch -"@typespec/playground": patch -"@typespec/versioning": patch -"@typespec/compiler": patch -"@typespec/openapi3": patch -"@typespec/protobuf": patch -"@typespec/bundler": patch -"@typespec/openapi": patch -"@typespec/samples": patch -"@typespec/website": patch -"@typespec/http": patch -"@typespec/rest": patch -"@typespec/spec": patch -"@typespec/tspd": patch -"@typespec/e2e": patch ---- - -Clean up docs diff --git a/.changeset/perfect-masks-jam.md b/.changeset/perfect-masks-jam.md new file mode 100644 index 000000000..a845151cc --- /dev/null +++ b/.changeset/perfect-masks-jam.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/package.json b/package.json index 1b5b99636..5f057b563 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "build": "pnpm -r --workspace-concurrency=Infinity --aggregate-output --reporter=append-only build ", "check-format": "pnpm run prettier --check", "check-version-mismatch": "syncpack list-mismatches", + "change": "changeset", "clean": "pnpm -r run clean", "cspell": "cspell --no-progress \"**/*.{md,ts,tsx}\" ", "dogfood": "pnpm install && pnpm build && pnpm -r dogfood", diff --git a/packages/website/src/components/homepage/hero-illustration/hero-illustration.module.css b/packages/website/src/components/homepage/hero-illustration/hero-illustration.module.css index 42aff3613..d2c16695c 100644 --- a/packages/website/src/components/homepage/hero-illustration/hero-illustration.module.css +++ b/packages/website/src/components/homepage/hero-illustration/hero-illustration.module.css @@ -8,7 +8,7 @@ } .split-windows { - height: 700px; + height: 600px; display: flex; flex-direction: row; align-items: stretch; diff --git a/packages/website/src/components/homepage/hero-illustration/hero-illustration.tsx b/packages/website/src/components/homepage/hero-illustration/hero-illustration.tsx index db1ba7f12..011cecdd7 100644 --- a/packages/website/src/components/homepage/hero-illustration/hero-illustration.tsx +++ b/packages/website/src/components/homepage/hero-illustration/hero-illustration.tsx @@ -1,8 +1,8 @@ -import openapiTsp from "!!raw-loader!@site/static/tsp-samples/openapi3/hero/main.tsp"; -import openapiYaml from "!!raw-loader!@site/static/tsp-samples/openapi3/hero/out/openapi.yaml"; +import openapiTsp from "!!raw-loader!@site/static/tsp-samples/homepage/hero/http/main.tsp"; +import openapiYaml from "!!raw-loader!@site/static/tsp-samples/homepage/hero/http/out/openapi.yaml"; -import jsonSchemaTsp from "!!raw-loader!@site/static/tsp-samples/json-schema/hero/main.tsp"; -import jsonSchemaOutput from "!!raw-loader!@site/static/tsp-samples/json-schema/hero/out/schema.yaml"; +import jsonSchemaTsp from "!!raw-loader!@site/static/tsp-samples/homepage/hero/json-schema/main.tsp"; +import jsonSchemaOutput from "!!raw-loader!@site/static/tsp-samples/homepage/hero/json-schema/out/schema.yaml"; import protobufTsp from "!!raw-loader!@site/static/tsp-samples/protobuf/hero/main.tsp"; import protobufOutput from "!!raw-loader!@site/static/tsp-samples/protobuf/hero/out/addressbook.proto"; diff --git a/packages/website/static/tsp-samples/homepage/hero/http/main.tsp b/packages/website/static/tsp-samples/homepage/hero/http/main.tsp new file mode 100644 index 000000000..0eab501ec --- /dev/null +++ b/packages/website/static/tsp-samples/homepage/hero/http/main.tsp @@ -0,0 +1,19 @@ +import "@typespec/http"; + +using TypeSpec.Http; + +model Store { + name: string; + address: Address; +} + +model Address { + street: string; + city: string; +} + +@route("/stores") +interface Stores { + list(@query filter: string): Store[]; + read(@path id: Store): Store; +} diff --git a/packages/website/static/tsp-samples/homepage/hero/http/out/openapi.yaml b/packages/website/static/tsp-samples/homepage/hero/http/out/openapi.yaml new file mode 100644 index 000000000..202d64b49 --- /dev/null +++ b/packages/website/static/tsp-samples/homepage/hero/http/out/openapi.yaml @@ -0,0 +1,62 @@ +openapi: 3.0.0 +info: + title: (title) + version: 0000-00-00 +tags: [] +paths: + /stores: + get: + operationId: Stores_list + parameters: + - name: filter + in: query + required: true + schema: + type: string + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Store' + /stores/{id}: + get: + operationId: Stores_read + parameters: + - name: id + in: path + required: true + schema: + $ref: '#/components/schemas/Store' + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + $ref: '#/components/schemas/Store' +components: + schemas: + Address: + type: object + required: + - street + - city + properties: + street: + type: string + city: + type: string + Store: + type: object + required: + - name + - address + properties: + name: + type: string + address: + $ref: '#/components/schemas/Address' diff --git a/packages/website/static/tsp-samples/homepage/hero/http/tspconfig.yaml b/packages/website/static/tsp-samples/homepage/hero/http/tspconfig.yaml new file mode 100644 index 000000000..9d91aa99f --- /dev/null +++ b/packages/website/static/tsp-samples/homepage/hero/http/tspconfig.yaml @@ -0,0 +1,4 @@ +emit: ["@typespec/openapi3"] +options: + "@typespec/openapi3": + emitter-output-dir: "{project-root}/out" diff --git a/packages/website/static/tsp-samples/homepage/hero/json-schema/main.tsp b/packages/website/static/tsp-samples/homepage/hero/json-schema/main.tsp new file mode 100644 index 000000000..bd3eb2642 --- /dev/null +++ b/packages/website/static/tsp-samples/homepage/hero/json-schema/main.tsp @@ -0,0 +1,25 @@ +import "@typespec/json-schema"; + +using TypeSpec.JsonSchema; + +@jsonSchema +namespace Schemas; + +model Person { + name: string; + address: Address; + @uniqueItems nickNames?: string[]; + cars?: Car[]; +} + +model Address { + street: string; + city: string; + country: string; +} + +model Car { + kind: "ev" | "ice"; + brand: string; + @minValue(1900) year: int32; +} diff --git a/packages/website/static/tsp-samples/homepage/hero/json-schema/out/schema.yaml b/packages/website/static/tsp-samples/homepage/hero/json-schema/out/schema.yaml new file mode 100644 index 000000000..5d6815357 --- /dev/null +++ b/packages/website/static/tsp-samples/homepage/hero/json-schema/out/schema.yaml @@ -0,0 +1,60 @@ +$schema: https://json-schema.org/draft/2020-12/schema +$id: schema.yaml +$defs: + Address: + $schema: https://json-schema.org/draft/2020-12/schema + $id: Address + type: object + properties: + street: + type: string + city: + type: string + country: + type: string + required: + - street + - city + - country + Car: + $schema: https://json-schema.org/draft/2020-12/schema + $id: Car + type: object + properties: + kind: + anyOf: + - type: string + const: ev + - type: string + const: ice + brand: + type: string + year: + type: integer + minimum: 1900 + maximum: 2147483647 + required: + - kind + - brand + - year + Person: + $schema: https://json-schema.org/draft/2020-12/schema + $id: Person + type: object + properties: + name: + type: string + address: + $ref: Address + nickNames: + type: array + items: + type: string + uniqueItems: true + cars: + type: array + items: + $ref: Car + required: + - name + - address diff --git a/packages/website/static/tsp-samples/homepage/hero/json-schema/tspconfig.yaml b/packages/website/static/tsp-samples/homepage/hero/json-schema/tspconfig.yaml new file mode 100644 index 000000000..1e82f39a3 --- /dev/null +++ b/packages/website/static/tsp-samples/homepage/hero/json-schema/tspconfig.yaml @@ -0,0 +1,5 @@ +emit: ["@typespec/json-schema"] +options: + "@typespec/json-schema": + emitter-output-dir: "{project-root}/out" + bundleId: schema.yaml diff --git a/packages/website/static/tsp-samples/openapi3/hero/out/openapi.yaml b/packages/website/static/tsp-samples/openapi3/hero/out/openapi.yaml index d402fa8c0..e55e6993c 100644 --- a/packages/website/static/tsp-samples/openapi3/hero/out/openapi.yaml +++ b/packages/website/static/tsp-samples/openapi3/hero/out/openapi.yaml @@ -80,15 +80,7 @@ paths: in: path required: true schema: - type: object - required: - - name - - address - properties: - name: - type: string - address: - $ref: '#/components/schemas/Address' + $ref: '#/components/schemas/Store' responses: '200': description: The request has succeeded.