Skip to content

Commit

Permalink
chore: rebase..
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanhitt committed Dec 24, 2024
1 parent 363f2f4 commit 49ae791
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions openapi.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package fuego

import (
"encoding/json"
"errors"
"fmt"
"log/slog"
"net/http"
"os"
"path/filepath"
"reflect"
"regexp"
"slices"
Expand Down Expand Up @@ -118,36 +114,6 @@ func (s *Server) OutputOpenAPISpec() openapi3.T {
return *s.OpenAPI.Description()
}

func (s *Server) marshalSpec() ([]byte, error) {
if s.OpenAPIConfig.PrettyFormatJson {
return json.MarshalIndent(s.OpenAPI.Description(), "", "\t")
}
return json.Marshal(s.OpenAPI.Description())
}

func (s *Server) saveOpenAPIToFile(jsonSpecLocalPath string, jsonSpec []byte) error {
jsonFolder := filepath.Dir(jsonSpecLocalPath)

err := os.MkdirAll(jsonFolder, 0o750)
if err != nil {
return errors.New("error creating docs directory")
}

f, err := os.Create(jsonSpecLocalPath) // #nosec G304 (file path provided by developer, not by user)
if err != nil {
return errors.New("error creating file")
}
defer f.Close()

_, err = f.Write(jsonSpec)
if err != nil {
return errors.New("error writing file ")
}

s.printOpenAPIMessage("JSON file: " + jsonSpecLocalPath)
return nil
}

// Registers the routes to serve the OpenAPI spec and Swagger UI.
func (s *Server) registerOpenAPIRoutes(jsonSpec []byte) {
GetStd(s, s.OpenAPIConfig.JsonURL, func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 49ae791

Please sign in to comment.