@@ -21,104 +21,99 @@ func main() {
2121 os .Exit (2 )
2222 }
2323
24- if true {
25- os .Exit (0 )
26- } else {
27-
28- outPath := os .Args [1 ]
29- out , err := getOutputFile (outPath )
30- if err != nil {
31- _ , _ = fmt .Fprintln (os .Stderr , "failed to open output file:" , err )
32- os .Exit (1 )
33- }
34- defer func () { _ = out .Close () }()
24+ outPath := os .Args [1 ]
25+ out , err := getOutputFile (outPath )
26+ if err != nil {
27+ _ , _ = fmt .Fprintln (os .Stderr , "failed to open output file:" , err )
28+ os .Exit (1 )
29+ }
30+ defer func () { _ = out .Close () }()
3531
36- // Create a new stdlib HTTP router.
37- mux := http .NewServeMux ()
32+ // Create a new stdlib HTTP router.
33+ mux := http .NewServeMux ()
3834
39- // Create a Huma v2 API on top of the router.
40- cfg := huma .DefaultConfig ("Indexer API" , "1.0.0" )
41- api := humago .New (mux , cfg )
35+ // Create a Huma v2 API on top of the router.
36+ cfg := huma .DefaultConfig ("Indexer API" , "1.0.0" )
37+ api := humago .New (mux , cfg )
4238
43- // Huma will use this to override its built in error type.
44- huma .NewError = func (status int , msg string , errs ... error ) huma.StatusError {
45- return v1.ErrorResponse {
46- Status : status ,
47- Message : msg ,
48- }
39+ // Huma will use this to override its built in error type.
40+ huma .NewError = func (status int , msg string , errs ... error ) huma.StatusError {
41+ return v1.ErrorResponse {
42+ Status : status ,
43+ Message : msg ,
4944 }
50- grp := huma .NewGroup (api , "/v1" )
51-
52- // Register root-level health and readiness endpoints (explicit type args)
53- huma .Register (api , huma.Operation {
54- OperationID : "health" ,
55- Method : http .MethodGet ,
56- Path : "/health" ,
57- Description : "Liveness probe that returns a plain 200." ,
58- }, func (ctx context.Context , _ * struct {}) (* struct {}, error ) {
59- return nil , nil
60- })
61-
62- huma .Register (api , huma.Operation {
63- OperationID : "ready" ,
64- Method : http .MethodGet ,
65- Path : "/ready" ,
66- Description : "Readiness probe that returns 200 if the service has storage access." ,
67- }, func (ctx context.Context , _ * struct {}) (* struct {}, error ) {
68- return nil , nil
69- })
70-
71- // Register v1 endpoints
72- huma .Register (grp , huma.Operation {
73- OperationID : "verifier-results" ,
74- Method : http .MethodGet ,
75- Path : "/verifierresults" ,
76- Description : "Get verifier results" ,
77- }, func (ctx context.Context , input * v1.VerifierResultsInput ) (* v1.VerifierResultsResponse , error ) {
78- return nil , nil
79- })
80-
81- huma .Register (grp , huma.Operation {
82- OperationID : "verifier-results-by-message-id" ,
83- Method : http .MethodGet ,
84- Path : "/verifierresults/{messageID}" ,
85- Description : "Get message by ID" ,
86- }, func (ctx context.Context , input * v1.VerifierResultsByMessageIDInput ) (* v1.VerifierResultsByMessageIDResponse , error ) {
87- return nil , nil
88- })
89-
90- huma .Register (grp , huma.Operation {
91- OperationID : "messages" ,
92- Method : http .MethodGet ,
93- Path : "/messages" ,
94- Description : "Get messages" ,
95- }, func (ctx context.Context , input * v1.MessagesInput ) (* v1.MessagesResponse , error ) {
96- return nil , nil
97- })
98-
99- oapi := api .OpenAPI ()
100-
101- // Remove $schema properties from all schemas (it was only in ErrorResponse)
102- if oapi .Components != nil {
103- for _ , schema := range oapi .Components .Schemas .Map () {
104- delete (schema .Properties , "$schema" )
105- }
106- }
107-
108- // yml, err := api.OpenAPI().Downgrade()
109- yml , err := api .OpenAPI ().DowngradeYAML ()
110- if err != nil {
111- _ , _ = fmt .Fprintln (os .Stderr , "failed to generate openapi yaml:" , err )
112- os .Exit (1 )
45+ }
46+ grp := huma .NewGroup (api , "/v1" )
47+
48+ // Register root-level health and readiness endpoints (explicit type args)
49+ huma .Register (api , huma.Operation {
50+ OperationID : "health" ,
51+ Method : http .MethodGet ,
52+ Path : "/health" ,
53+ Description : "Liveness probe that returns a plain 200." ,
54+ }, func (ctx context.Context , _ * struct {}) (* struct {}, error ) {
55+ return nil , nil
56+ })
57+
58+ huma .Register (api , huma.Operation {
59+ OperationID : "ready" ,
60+ Method : http .MethodGet ,
61+ Path : "/ready" ,
62+ Description : "Readiness probe that returns 200 if the service has storage access." ,
63+ }, func (ctx context.Context , _ * struct {}) (* struct {}, error ) {
64+ return nil , nil
65+ })
66+
67+ // Register v1 endpoints
68+ huma .Register (grp , huma.Operation {
69+ OperationID : "verifier-results" ,
70+ Method : http .MethodGet ,
71+ Path : "/verifierresults" ,
72+ Description : "Get verifier results" ,
73+ }, func (ctx context.Context , input * v1.VerifierResultsInput ) (* v1.VerifierResultsResponse , error ) {
74+ return nil , nil
75+ })
76+
77+ huma .Register (grp , huma.Operation {
78+ OperationID : "verifier-results-by-message-id" ,
79+ Method : http .MethodGet ,
80+ Path : "/verifierresults/{messageID}" ,
81+ Description : "Get message by ID" ,
82+ }, func (ctx context.Context , input * v1.VerifierResultsByMessageIDInput ) (* v1.VerifierResultsByMessageIDResponse , error ) {
83+ return nil , nil
84+ })
85+
86+ huma .Register (grp , huma.Operation {
87+ OperationID : "messages" ,
88+ Method : http .MethodGet ,
89+ Path : "/messages" ,
90+ Description : "Get messages" ,
91+ }, func (ctx context.Context , input * v1.MessagesInput ) (* v1.MessagesResponse , error ) {
92+ return nil , nil
93+ })
94+
95+ oapi := api .OpenAPI ()
96+
97+ // Remove $schema properties from all schemas (it was only in ErrorResponse)
98+ if oapi .Components != nil {
99+ for _ , schema := range oapi .Components .Schemas .Map () {
100+ delete (schema .Properties , "$schema" )
113101 }
102+ }
114103
115- if _ , err := out .Write (yml ); err != nil {
116- _ , _ = fmt .Fprintln (os .Stderr , "failed to write file:" , err )
117- os .Exit (1 )
118- }
104+ // yml, err := api.OpenAPI().Downgrade()
105+ yml , err := api .OpenAPI ().DowngradeYAML ()
106+ if err != nil {
107+ _ , _ = fmt .Fprintln (os .Stderr , "failed to generate openapi yaml:" , err )
108+ os .Exit (1 )
109+ }
119110
120- _ , _ = fmt .Fprintf (os .Stderr , "wrote OpenAPI YAML to %s\n " , outPath )
111+ if _ , err := out .Write (yml ); err != nil {
112+ _ , _ = fmt .Fprintln (os .Stderr , "failed to write file:" , err )
113+ os .Exit (1 )
121114 }
115+
116+ _ , _ = fmt .Fprintf (os .Stderr , "wrote OpenAPI YAML to %s\n " , outPath )
122117}
123118
124119func getOutputFile (path string ) (* os.File , error ) {
0 commit comments