Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hello world, use inlined files instead of strings #1614

Merged
merged 2 commits into from
Oct 23, 2024
Merged
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
13,107 changes: 13,107 additions & 0 deletions modules/website/package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion modules/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"dependencies": {
"@docusaurus/core": "2.4.3",
"@docusaurus/preset-classic": "2.4.3",
"docusaurus-lunr-search": "3.5.0",
"@mdx-js/react": "^1.6.21",
"clsx": "^2.1.1",
"docusaurus-lunr-search": "3.5.0",
"prism-react-renderer": "^2.1.0",
"react": "^17.0.1",
"react-dom": "^17.0.1"
Expand All @@ -34,5 +34,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"raw-loader": "^4.0.2"
}
}
9 changes: 6 additions & 3 deletions modules/website/src/components/HomepageFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import React from 'react';
import clsx from 'clsx';
import styles from './HomepageFeatures.module.css';
import CodeBlock from '@theme/CodeBlock';
import HelloWorldSmithy from 'raw-loader!./sample_data/HelloWorld.smithy';
import HelloWorldRoutes from 'raw-loader!./sample_data/HelloWorldRoutes.scala';
import HelloWorldImpl from 'raw-loader!./sample_data/HelloWorldImpl.scala';

const FeatureList = [
{
title: '1. Define API Contract',
lang: "smithy",
content: "service AdminService {\n operations: [GetUser]\n}\n\n@http(method: \"GET\", uri: \"/user/{id}\")\noperation GetUser {\n input := {\n @required\n @httpLabel\n id: String\n }\n output: User\n}\n\nstructure User {\n @required firstName: String\n @required lastName: String\n}",
content: HelloWorldSmithy,
description: (
<>
Start by defining your API in <b>Smithy</b>, a concise, readable, language-agnostic
Expand All @@ -33,7 +36,7 @@ const FeatureList = [
{
title: '2. Implement Generated Interface',
lang: "scala",
content: "object AdminServiceImpl extends AdminService[IO] {\n def getUser(id: String): IO[User] = ...\n}",
content: HelloWorldImpl,
description: (
<>
<b>Smithy4s</b> uses the Smithy model you define to generate Scala code, including an interface that represents the service. This interface contains one method per service operation.
Expand All @@ -43,7 +46,7 @@ const FeatureList = [
{
title: '3. Transform Into HttpRoutes',
lang: "scala",
content: "val routes: Resource[IO, HttpRoutes[IO]] =\n SimpleRestJsonBuilder.routes(AdminServiceImpl).resource",
content: HelloWorldRoutes,
description: (
<>
Passing your service implementation to the SimpleRestJsonBuilder gives you an HttpRoutes instance that handles HTTP routing and JSON serialization/deserialization.
Expand Down
22 changes: 22 additions & 0 deletions modules/website/src/components/sample_data/HelloWorld.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
$version: "2.0"

namespace smithy4s.hello

service AdminService {
operations: [GetUser]
}

@http(method: "GET", uri: "/user/{id}")
operation GetUser {
input := {
@required
@httpLabel
id: String
}
output: User
}

structure User {
@required firstName: String
@required lastName: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object AdminServiceImpl extends AdminService[IO] {
def getUser(id: String): IO[User] = ???
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
val routes: Resource[IO, HttpRoutes[IO]] =
SimpleRestJsonBuilder.routes(AdminServiceImpl).resource
2,111 changes: 1,057 additions & 1,054 deletions modules/website/yarn.lock

Large diffs are not rendered by default.