Skip to content

Commit 77166e4

Browse files
Merge pull request #1 from speakeasy-api/extension-parsing
feat: add support for parsing extensions into custom models
2 parents 30fe8fb + e0d66b1 commit 77166e4

26 files changed

+254
-61
lines changed

arazzo/arazzo.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ func Unmarshal(ctx context.Context, doc io.Reader, opts ...Option[unmarshalOptio
7373
if err := marshaller.PopulateModel(*c, arazzo); err != nil {
7474
return nil, nil, err
7575
}
76-
arazzo.core = *c
7776

7877
var validationErrs []error
7978
if !o.skipValidation {

arazzo/arazzo_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ func TestArazzo_Unmarshal_Success(t *testing.T) {
191191
expected := testArazzoInstance
192192

193193
assert.EqualExportedValues(t, expected, a)
194-
assert.Equal(t, expected.Extensions, a.Extensions)
195-
assert.Equal(t, expected.Info.Extensions, a.Info.Extensions)
194+
assert.EqualExportedValues(t, expected.Extensions, a.Extensions)
195+
assert.EqualExportedValues(t, expected.Info.Extensions, a.Info.Extensions)
196196
for i, sourceDescription := range expected.SourceDescriptions {
197-
assert.Equal(t, sourceDescription.Extensions, a.SourceDescriptions[i].Extensions)
197+
assert.EqualExportedValues(t, sourceDescription.Extensions, a.SourceDescriptions[i].Extensions)
198198
}
199199
}
200200

@@ -271,10 +271,10 @@ sourceDescriptions:
271271
}
272272

273273
assert.EqualExportedValues(t, expected, a)
274-
assert.Equal(t, expected.Extensions, a.Extensions)
275-
assert.Equal(t, expected.Info.Extensions, a.Info.Extensions)
274+
assert.EqualExportedValues(t, expected.Extensions, a.Extensions)
275+
assert.EqualExportedValues(t, expected.Info.Extensions, a.Info.Extensions)
276276
for i, sourceDescription := range expected.SourceDescriptions {
277-
assert.Equal(t, sourceDescription.Extensions, a.SourceDescriptions[i].Extensions)
277+
assert.EqualExportedValues(t, sourceDescription.Extensions, a.SourceDescriptions[i].Extensions)
278278
}
279279
}
280280

arazzo/core/arazzo.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"io"
77

8+
"github.com/speakeasy-api/openapi/extensions/core"
89
"github.com/speakeasy-api/openapi/json"
910
"github.com/speakeasy-api/openapi/marshaller"
1011
"github.com/speakeasy-api/openapi/yml"
@@ -17,7 +18,7 @@ type Arazzo struct {
1718
SourceDescriptions marshaller.Node[[]SourceDescription] `key:"sourceDescriptions" required:"true"`
1819
Workflows marshaller.Node[[]Workflow] `key:"workflows" required:"true"`
1920
Components marshaller.Node[*Components] `key:"components"`
20-
Extensions Extensions `key:"extensions"`
21+
Extensions core.Extensions `key:"extensions"`
2122

2223
RootNode *yaml.Node
2324
Config *yml.Config

arazzo/core/components.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package core
33
import (
44
"context"
55

6+
coreExtensions "github.com/speakeasy-api/openapi/extensions/core"
67
"github.com/speakeasy-api/openapi/jsonschema/oas31/core"
78
"github.com/speakeasy-api/openapi/marshaller"
89
"github.com/speakeasy-api/openapi/sequencedmap"
@@ -14,7 +15,7 @@ type Components struct {
1415
Parameters marshaller.Node[*sequencedmap.Map[string, Parameter]] `key:"parameters"`
1516
SuccessActions marshaller.Node[*sequencedmap.Map[string, SuccessAction]] `key:"successActions"`
1617
FailureActions marshaller.Node[*sequencedmap.Map[string, FailureAction]] `key:"failureActions"`
17-
Extensions Extensions `key:"extensions"`
18+
Extensions coreExtensions.Extensions `key:"extensions"`
1819

1920
RootNode *yaml.Node
2021
}

arazzo/core/criterion.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"reflect"
77

8+
"github.com/speakeasy-api/openapi/extensions/core"
89
"github.com/speakeasy-api/openapi/marshaller"
910
"gopkg.in/yaml.v3"
1011
)
@@ -86,7 +87,7 @@ type Criterion struct {
8687
Context marshaller.Node[*Expression] `key:"context"`
8788
Condition marshaller.Node[string] `key:"condition"`
8889
Type marshaller.Node[CriterionTypeUnion] `key:"type" required:"false"`
89-
Extensions Extensions `key:"extensions"`
90+
Extensions core.Extensions `key:"extensions"`
9091

9192
RootNode *yaml.Node
9293
}

arazzo/core/extensions.go

Lines changed: 0 additions & 9 deletions
This file was deleted.

arazzo/core/failureaction.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package core
33
import (
44
"context"
55

6+
"github.com/speakeasy-api/openapi/extensions/core"
67
"github.com/speakeasy-api/openapi/marshaller"
78
"gopkg.in/yaml.v3"
89
)
@@ -15,7 +16,7 @@ type FailureAction struct {
1516
RetryAfter marshaller.Node[*float64] `key:"retryAfter"`
1617
RetryLimit marshaller.Node[*int] `key:"retryLimit"`
1718
Criteria marshaller.Node[[]Criterion] `key:"criteria"`
18-
Extensions Extensions `key:"extensions"`
19+
Extensions core.Extensions `key:"extensions"`
1920

2021
RootNode *yaml.Node
2122
}

arazzo/core/info.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package core
33
import (
44
"context"
55

6+
"github.com/speakeasy-api/openapi/extensions/core"
67
"github.com/speakeasy-api/openapi/marshaller"
78
"gopkg.in/yaml.v3"
89
)
@@ -12,7 +13,7 @@ type Info struct {
1213
Summary marshaller.Node[*string] `key:"summary"`
1314
Description marshaller.Node[*string] `key:"description"`
1415
Version marshaller.Node[string] `key:"version"`
15-
Extensions Extensions `key:"extensions"`
16+
Extensions core.Extensions `key:"extensions"`
1617

1718
RootNode *yaml.Node
1819
}

arazzo/core/parameter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package core
33
import (
44
"context"
55

6+
"github.com/speakeasy-api/openapi/extensions/core"
67
"github.com/speakeasy-api/openapi/marshaller"
78
"gopkg.in/yaml.v3"
89
)
@@ -11,7 +12,7 @@ type Parameter struct {
1112
Name marshaller.Node[string] `key:"name"`
1213
In marshaller.Node[*string] `key:"in"`
1314
Value marshaller.Node[ValueOrExpression] `key:"value" required:"true"`
14-
Extensions Extensions `key:"extensions"`
15+
Extensions core.Extensions `key:"extensions"`
1516

1617
RootNode *yaml.Node
1718
}

arazzo/core/payloadreplacement.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package core
33
import (
44
"context"
55

6+
"github.com/speakeasy-api/openapi/extensions/core"
67
"github.com/speakeasy-api/openapi/marshaller"
78
"gopkg.in/yaml.v3"
89
)
910

1011
type PayloadReplacement struct {
1112
Target marshaller.Node[string] `key:"target"`
1213
Value marshaller.Node[ValueOrExpression] `key:"value" required:"true"`
13-
Extensions Extensions `key:"extensions"`
14+
Extensions core.Extensions `key:"extensions"`
1415

1516
RootNode *yaml.Node
1617
}

0 commit comments

Comments
 (0)