Skip to content

Commit

Permalink
remove writer function
Browse files Browse the repository at this point in the history
  • Loading branch information
losisin committed Dec 9, 2023
1 parent 38f2e27 commit d32a940
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 103 deletions.
11 changes: 9 additions & 2 deletions pkg/generator.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pkg

import (
"encoding/json"
"errors"
"fmt"
"os"
Expand Down Expand Up @@ -68,9 +69,15 @@ func GenerateJsonSchema(config *Config) error {
}

Check warning on line 69 in pkg/generator.go

View check run for this annotation

Codecov / codecov/patch

pkg/generator.go#L68-L69

Added lines #L68 - L69 were not covered by tests
jsonSchemaMap["$schema"] = schemaURL // Include the schema draft version

err = writeMap(jsonSchemaMap, config.outputPath)
// If validation is successful, marshal the schema and save to the file
jsonBytes, err := json.MarshalIndent(jsonSchemaMap, "", " ")
if err != nil {
fmt.Printf("Error: %v\n", err)
return err
}

Check warning on line 76 in pkg/generator.go

View check run for this annotation

Codecov / codecov/patch

pkg/generator.go#L75-L76

Added lines #L75 - L76 were not covered by tests

outputPath := config.outputPath
if err := os.WriteFile(outputPath, jsonBytes, 0644); err != nil {
return fmt.Errorf("error writing JSON schema to file '%s': %v", outputPath, err)
}

Check warning on line 81 in pkg/generator.go

View check run for this annotation

Codecov / codecov/patch

pkg/generator.go#L80-L81

Added lines #L80 - L81 were not covered by tests

return nil
Expand Down
37 changes: 0 additions & 37 deletions pkg/writter.go

This file was deleted.

64 changes: 0 additions & 64 deletions pkg/writter_test.go

This file was deleted.

0 comments on commit d32a940

Please sign in to comment.