Skip to content

Commit

Permalink
Downgrade yaml to support ordered map parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethnym committed Jan 29, 2024
1 parent f0d3c67 commit a7609e1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -4,5 +4,5 @@ go 1.20

require (
github.com/iancoleman/strcase v0.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
@@ -1,5 +1,7 @@
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
8 changes: 5 additions & 3 deletions internal/parser/parse.go
Expand Up @@ -2,7 +2,7 @@ package parser

import (
"errors"
"gopkg.in/yaml.v3"
"gopkg.in/yaml.v2"
"nanoc/internal/datatype"
"nanoc/internal/symbol"
"os"
Expand All @@ -15,15 +15,17 @@ func ParseSchema(path string) (datatype.PartialSchema, error) {
return nil, err
}

m := map[string]interface{}{}
m := yaml.MapSlice{}
err = yaml.Unmarshal(b, m)
if err != nil {
return nil, err
}

var schema datatype.PartialSchema

for k, v := range m {
for _, e := range m {
k := e.Key.(string)
v := e.Value
if strings.HasPrefix(k, symbol.Enum+" ") {
s, err := parseEnumSchema(k, v)
if err != nil {
Expand Down

0 comments on commit a7609e1

Please sign in to comment.