Skip to content

Commit

Permalink
Merge pull request #22 from e2b-dev/fix/missing-spec
Browse files Browse the repository at this point in the history
Fix missing spec
  • Loading branch information
jakubno committed Aug 3, 2023
2 parents fa38a41 + 00501f4 commit fb8b1ba
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 11 deletions.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
Expand Down
15 changes: 12 additions & 3 deletions agent/js/package-lock.json

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

4 changes: 3 additions & 1 deletion agent/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agent-protocol",
"version": "0.1.1",
"version": "0.1.2",
"description": "API for interacting with Agent",
"homepage": "https://e2b.dev",
"license": "MIT",
Expand All @@ -24,6 +24,7 @@
"private": false,
"devDependencies": {
"@types/express": "^4.17.17",
"@types/js-yaml": "^4.0.5",
"@types/node": "^20.4.1",
"@types/uuid": "^9.0.2",
"prettier": "^3.0.0",
Expand Down Expand Up @@ -51,6 +52,7 @@
"dependencies": {
"express": "^4.18.2",
"express-openapi-validator": "^5.0.4",
"js-yaml": "^4.1.0",
"uuid": "^9.0.0"
}
}
14 changes: 9 additions & 5 deletions agent/js/src/agent.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as OpenApiValidator from 'express-openapi-validator'

Check failure on line 1 in agent/js/src/agent.ts

View workflow job for this annotation

GitHub Actions / Check typescript

Cannot find module 'express-openapi-validator' or its corresponding type declarations.

Check failure on line 1 in agent/js/src/agent.ts

View workflow job for this annotation

GitHub Actions / Check typescript

Cannot find module 'express' or its corresponding type declarations.

Check failure on line 1 in agent/js/src/agent.ts

View workflow job for this annotation

GitHub Actions / Check typescript

Cannot find module 'uuid' or its corresponding type declarations.
import express from 'express'
import path from 'path'

import { v4 as uuid } from 'uuid'
import yaml from 'js-yaml'

import {
type TaskInput,
type Artifact,
Expand All @@ -15,19 +15,23 @@ import {
type TaskRequestBody,
} from './models'

import spec from '../../../openapi.yml'

const app = express()

app.use(express.json())
app.use(express.text())
app.use(express.urlencoded({ extended: false }))

const spec = path.join(__dirname, '../../openapi.yml')
app.get('/openapi.yaml', (_, res) => {
res.setHeader('Content-Type', 'text/yaml').status(200).send(spec)
})

app.use('/spec', express.static(spec))
const parsedSpec = yaml.load(spec)

app.use(
OpenApiValidator.middleware({
apiSpec: '../openapi.yml',
apiSpec: parsedSpec as any,
validateRequests: true, // (default)
validateResponses: true, // false by default
})
Expand Down
4 changes: 4 additions & 0 deletions agent/js/src/yml.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.yml' {
const content: string
export default content
}
5 changes: 5 additions & 0 deletions agent/js/tsup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ export default defineConfig({
target: 'node16',
platform: 'node',
format: 'cjs',
minify: true,
sourcemap: true,
dts: true,
loader: {
'.yml': 'text',
},
})
1 change: 1 addition & 0 deletions agent/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ To get response like this:
```

## Test compliance

Part of the package is also a test suite that can be used to test compliance with the protocol. To run the tests, run the following command:

```sh
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"sourceMap": false,
"outDir": "./dist",
"baseUrl": "./",
"strictNullChecks": true
"strictNullChecks": true,
"esModuleInterop": true
},
"exclude": ["node_modules", "test", "lib", "**/*spec.ts", "dist"]
}

0 comments on commit fb8b1ba

Please sign in to comment.