Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions cmd/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
Long: helpdocs.MustRender("schema/dereference"),
RunE: runSchemaDereference,
}
schemaDereferenceCmd.Flags().StringP("file", "f", "", "Path to JSON document (use - for stdin)")
schemaDereferenceCmd.Flags().StringP("file", "f", "", "Path to JSON document")
schemaDereferenceCmd.MarkFlagRequired("file")

Check failure on line 31 in cmd/schema.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `schemaDereferenceCmd.MarkFlagRequired` is not checked (errcheck)

schemaValidateCmd := &cobra.Command{
Use: "validate",
Expand All @@ -38,8 +38,8 @@
}
schemaValidateCmd.Flags().StringP("document", "d", "document.json", "Path to JSON document")
schemaValidateCmd.Flags().StringP("schema", "s", "./schema.json", "Path to JSON Schema")
schemaValidateCmd.MarkFlagRequired("document")

Check failure on line 41 in cmd/schema.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `schemaValidateCmd.MarkFlagRequired` is not checked (errcheck)
schemaValidateCmd.MarkFlagRequired("schema")

Check failure on line 42 in cmd/schema.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `schemaValidateCmd.MarkFlagRequired` is not checked (errcheck)

schemaCmd.AddCommand(schemaDereferenceCmd)
schemaCmd.AddCommand(schemaValidateCmd)
Expand All @@ -51,19 +51,12 @@
schemaPath, _ := cmd.Flags().GetString("file")
cmd.SilenceUsage = true

var schemaFile *os.File
basePath := "."
if schemaPath == "-" {
schemaFile = os.Stdin
} else {
var openErr error
schemaFile, openErr = os.Open(schemaPath)
basePath = filepath.Dir(schemaPath)
if openErr != nil {
return fmt.Errorf("failed to open schema file %s: %w", schemaPath, openErr)
}
defer schemaFile.Close()
schemaFile, openErr := os.Open(schemaPath)
if openErr != nil {
return fmt.Errorf("failed to open schema file %s: %w", schemaPath, openErr)
}
defer schemaFile.Close()
basePath := filepath.Dir(schemaPath)

var rawSchema map[string]any
if err := json.NewDecoder(schemaFile).Decode(&rawSchema); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/mass_schema_dereference.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mass schema dereference [flags]
### Options

```
-f, --file string Path to JSON document (use - for stdin)
-f, --file string Path to JSON document
-h, --help help for dereference
```

Expand Down
Loading