# OR use dedicated docker image
docker run -t --rm -v $(pwd)/src:/app -w /app parvez3019/go-swagger3:latest --main-file-path /app/main.go --module-path . --output oas.json --schema-without-pkg --generate-yaml true
```

In your `src` folder, you'll now have a schema called `oas.yml`:

```yml
components:
  schemas:
	RequestBody:
	  properties:
		name:
		  type: string
	  type: object
info:
  description: Say hi to the name given
  title: Hello
  version: 1.0.0
openapi: 3.0.0
paths:
  /helloHandler:
	post:
	  description: ' Say hi to the name given'
	  requestBody:
		content:
		  application/json:
			schema:
			  $ref: '#/components/schemas/RequestBody'
		required: true
	  responses:
		"200":
		  content:
			application/json:
			  schema:
				type: string
		  description: Responds with 'Hello {name}'
	  summary: Hello
servers:
- description: Default Server URL
  url: /
```

## Attribute annotation

All the considerations raised about comment annotations in the previous section also apply to attribute annotations, except that attribute annotations are safer than comment annotations as they can be parsed by a compiler.

### Example attribute annotation with an OpenAPI-aware framework in Go

To demonstrate attribute annotation, we'll use a framework called [Huma](https://huma.rocks/), which [supports many Go routers](https://huma.rocks/features/bring-your-own-router). Unlike a simple annotation plugin that sits above your existing code, Huma requires you to alter your operations to use the Huma context object. While Huma doesn't support the standard Go `net/http` router, it does support the more complex `mux` handler.

If you'd like to follow along, use the existing `main.go` file from the previous section.

First, install Huma:

```sh
docker run --rm -v $(pwd)/src:/app -w /app golang:1.23-alpine3.19    go get github.com/danielgtaylor/huma/v2 github.com/danielgtaylor/huma/v2/adapters/humago
```

Update `main.go` to use Huma with the changes below.

```go
package main

import (
	  // "encoding/json"
	  "fmt"
	  "log"
	  "net/http"

	  "context"
	  "github.com/danielgtaylor/huma/v2" // NEW
	  "github.com/danielgtaylor/huma/v2/adapters/humago"
)

type RequestBody struct {
	  // Name string `json:"name"`
	  Body struct {
		Name string `json:"name" maxLength:"30" example:"world" doc:"Name to greet"`
	}
}

//NEW
type ResponseBody struct {
	Body struct {
		Message string `json:"message"`
	}
}

func main() {
	  mux := http.NewServeMux()
	  api := humago.New(mux, huma.DefaultConfig("Hello API", "1.0.0")) // NEW
	huma.Post(api, "/hello", helloHandler) // NEW

	  log.Println("Server started on port 8080")
	  log.Fatal(http.ListenAndServe(":8080", mux))
}

 // NEW
func helloHandler(ctx context.Context, input *RequestBody) (*ResponseBody, error) {
	response := &ResponseBody {
		Body: struct { Message string `json:"message"`}{
			Message: fmt.Sprintf("Hello %s", input.Body.Name),
		},
	}
	  return response, nil
}
```

Note that the code above has changed the request and response types to have a `Body` section. Huma returns a schema object in the response at the same level as `Body`. The `main` function no longer uses the router in the same way, but now uses Huma to declare routes.

Now run the server.

```sh
docker run --rm  -p 65000:8080 -v $(pwd)/src:/app -w /app golang:1.23-alpine3.19 /bin/sh -c   "go build && ./helloworld"