MCPcopy
hub / github.com/danielgtaylor/huma / TestOpenAPIMarshal

Function TestOpenAPIMarshal

openapi_test.go:12–172  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestOpenAPIMarshal(t *testing.T) {
13 // Simple spot check to make sure we are generating valid YAML and that
14 // the OpenAPI generally works as expected.
15
16 num := 1.0
17
18 v := huma.OpenAPI{
19 OpenAPI: "3.0.0",
20 Info: &huma.Info{
21 Title: "Test API",
22 Version: "1.0.0",
23 Contact: &huma.Contact{
24 Name: "Daniel Taylor",
25 },
26 License: &huma.License{
27 Name: "MIT",
28 },
29 },
30 ExternalDocs: &huma.ExternalDocs{
31 URL: "https://example.com",
32 },
33 Tags: []*huma.Tag{
34 {
35 Name: "test",
36 },
37 },
38 Servers: []*huma.Server{
39 {
40 URL: "https://example.com/{foo}",
41 Variables: map[string]*huma.ServerVariable{
42 "foo": {
43 Default: "bar",
44 Enum: []string{"bar", "baz"},
45 },
46 },
47 },
48 },
49 Components: &huma.Components{
50 Schemas: huma.NewMapRegistry("#/components/schemas/", huma.DefaultSchemaNamer),
51 SecuritySchemes: map[string]*huma.SecurityScheme{
52 "oauth2": {
53 Type: "oauth2",
54 Flows: &huma.OAuthFlows{
55 ClientCredentials: &huma.OAuthFlow{
56 AuthorizationURL: "https://example.com/oauth2/authorize",
57 TokenURL: "https://example.com/oauth2/token",
58 Scopes: map[string]string{
59 "test": "Test scope",
60 },
61 },
62 },
63 },
64 },
65 },
66 Paths: map[string]*huma.PathItem{
67 "/test": {
68 Get: &huma.Operation{
69 Responses: map[string]*huma.Response{

Callers

nothing calls this directly

Calls 1

YAMLMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…