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

Add Instructions to run generated code in JS(axios, fetch) and Go #626

Merged
merged 3 commits into from
Mar 1, 2025
Merged
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
91 changes: 88 additions & 3 deletions doc/user_guide/instructions_to_run_generated_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,100 @@ Here are the detailed instructions for running the generated API Dash code in **

## Go (net/http)

TODO
### 1. Install Go compiler

- Windows and MacOS: check out the [official source](https://go.dev/doc/install)
- Linux: Install from your distro's package manager.

Verify if go is installed:

```bash
go version
```

### 2. Create a project
```bash
go mod init example.com/api
```

### 3. Run the generated code
- Paste the generated code into `main.go`.
- Build and run by `go run main.go`.

## JavaScript (axios)

TODO
The generated api code can be run in browser by using the code in an html file as demonstrated below:

### 1. Create the html file with generated code

Create a new file `index.html`

```html
<!DOCTYPE html>
<html>
<head>
<title>Axios Example</title>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
<script>
// Paste your API Dash generated code here !!
</script>
</body>
</html>

```

Make sure to paste the generated js code from api dash under the `<script>` tag.

### 2. Test with Browser Developer Tools

Open the `index.html` file in a modern browser and open devtools.

- **Chrome**: Right-click the page and select "Inspect" or press Ctrl+Shift+I (Windows/Linux) or Cmd+Option+I (macOS).

- **Firefox**: Right-click the page and select "Inspect Element" or press Ctrl+Shift+I (Windows/Linux) or Cmd+Option+I (macOS).

- **Edge**: Right-click the page and select "Inspect" or press F12 or Ctrl+Shift+I.

Navigate to network tab and refresh the page to see the requests and network activity.

## JavaScript (fetch)

TODO
The generated api code can be run in browser by using the code in an html file as demonstrated below:

### 1. Create the html file with generated code

Create a new file `index.html`

```html
<!DOCTYPE html>
<html>
<head>
<title>Fetch Example</title>
</head>
<body>
<script>
// Paste your API Dash generated code here !!
</script>
</body>
</html>

```

Make sure to paste the generated js code from api dash under the `<script>` tag.

### 2. Test with Browser Developer Tools

Open the `index.html` file in a modern browser and open devtools.

- **Chrome**: Right-click the page and select "Inspect" or press Ctrl+Shift+I (Windows/Linux) or Cmd+Option+I (macOS).

- **Firefox**: Right-click the page and select "Inspect Element" or press Ctrl+Shift+I (Windows/Linux) or Cmd+Option+I (macOS).

- **Edge**: Right-click the page and select "Inspect" or press F12 or Ctrl+Shift+I.

Navigate to network tab and refresh the page to see the requests and network activity.

## node.js (JavaScript, axios)

Expand Down