Skip to content

Commit

Permalink
Update dynamic schema example
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop committed Aug 26, 2023
1 parent 5f85765 commit f483e1c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions _examples/advanced/_testdata/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"200":{
"description":"OK",
"headers":{"foo":{"style":"simple","schema":{"enum":["123","456","789"],"type":"integer"}}},
"content":{"application/dummy+json":{"schema":{"$ref":"#/components/schemas/AdvancedDynamicOutput"}}}
"content":{"application/dummy+json":{"schema":{"$ref":"#/components/schemas/DynOut123"}}}
},
"400":{
"description":"Bad Request",
Expand Down Expand Up @@ -492,7 +492,6 @@
"schemas":{
"AdvancedAnotherErr":{"type":"object","properties":{"foo":{"type":"integer"}}},
"AdvancedCustomErr":{"type":"object","properties":{"details":{"type":"object","additionalProperties":{}},"msg":{"type":"string"}}},
"AdvancedDynamicOutput":{"type":"object","properties":{"bar":{"type":"string"},"status":{"type":"string"}}},
"AdvancedGzipPassThroughStruct":{
"type":"object",
"properties":{"id":{"type":"integer"},"text":{"type":"array","items":{"type":"string"},"nullable":true}}
Expand Down Expand Up @@ -596,6 +595,7 @@
"name":{"minLength":3,"type":"string"}
}
},
"DynOut123":{"type":"object","properties":{"bar":{"type":"string"},"status":{"type":"string"}}},
"FormDataAdvancedInputPort":{
"required":["val2"],"type":"object",
"properties":{"val2":{"minimum":3,"type":"integer","description":"Simple scalar value with sample validation."}},
Expand Down
2 changes: 2 additions & 0 deletions _examples/advanced/dynamic_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ func (o dynamicOutput) MarshalJSON() ([]byte, error) {

func dynamicSchema() usecase.Interactor {
dynIn := dynamicInput{}
dynIn.DefName = "DynIn123"
dynIn.Struct.Fields = []jsonschema.Field{
{Name: "Foo", Value: 123, Tag: `header:"foo" enum:"123,456,789"`},
{Name: "Bar", Value: "abc", Tag: `query:"bar"`},
}

dynOut := dynamicOutput{}
dynOut.DefName = "DynOut123"
dynOut.Struct.Fields = []jsonschema.Field{
{Name: "Foo", Value: 123, Tag: `header:"foo" enum:"123,456,789"`},
{Name: "Bar", Value: "abc", Tag: `json:"bar"`},
Expand Down
2 changes: 1 addition & 1 deletion _examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/rs/cors v1.9.0
github.com/stretchr/testify v1.8.4
github.com/swaggest/assertjson v1.9.0
github.com/swaggest/jsonschema-go v0.3.58
github.com/swaggest/jsonschema-go v0.3.59
github.com/swaggest/openapi-go v0.2.39
github.com/swaggest/rest v0.0.0-00010101000000-000000000000
github.com/swaggest/swgui v1.7.2
Expand Down
4 changes: 2 additions & 2 deletions _examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7
github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU=
github.com/swaggest/form/v5 v5.1.1 h1:ct6/rOQBGrqWUQ0FUv3vW5sHvTUb31AwTUWj947N6cY=
github.com/swaggest/form/v5 v5.1.1/go.mod h1:X1hraaoONee20PMnGNLQpO32f9zbQ0Czfm7iZThuEKg=
github.com/swaggest/jsonschema-go v0.3.58 h1:OPixN4HW9H3FTh9BSomH2i0bdJi3V646TfSihzt9QBc=
github.com/swaggest/jsonschema-go v0.3.58/go.mod h1:5WFFGBBte5JAWAV8gDpNRJ/tlQnb1AHDdf/ghgsVUik=
github.com/swaggest/jsonschema-go v0.3.59 h1:BoPhtNvWbZRo1Wl6xvR3g6WL01COJTOAs6vMUnZgocM=
github.com/swaggest/jsonschema-go v0.3.59/go.mod h1:5WFFGBBte5JAWAV8gDpNRJ/tlQnb1AHDdf/ghgsVUik=
github.com/swaggest/openapi-go v0.2.39 h1:GfICsAAFnQuyxfywsGyCbPqDKeMXxots4N/9j6+qSCk=
github.com/swaggest/openapi-go v0.2.39/go.mod h1:g+AfRIkPCHdhqfW8zOD1Sk3PwLhxpWW8SNWHXrmA08c=
github.com/swaggest/refl v1.2.1 h1:1meX9NaXjM5lmb4kk4RP3OZsXFRke9B1EHAP/pCEKO0=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/stretchr/testify v1.8.2
github.com/swaggest/assertjson v1.9.0
github.com/swaggest/form/v5 v5.1.1
github.com/swaggest/jsonschema-go v0.3.58
github.com/swaggest/jsonschema-go v0.3.59
github.com/swaggest/openapi-go v0.2.39
github.com/swaggest/refl v1.2.1
github.com/swaggest/usecase v1.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUb
github.com/swaggest/form/v5 v5.1.1 h1:ct6/rOQBGrqWUQ0FUv3vW5sHvTUb31AwTUWj947N6cY=
github.com/swaggest/form/v5 v5.1.1/go.mod h1:X1hraaoONee20PMnGNLQpO32f9zbQ0Czfm7iZThuEKg=
github.com/swaggest/jsonschema-go v0.3.57/go.mod h1:5WFFGBBte5JAWAV8gDpNRJ/tlQnb1AHDdf/ghgsVUik=
github.com/swaggest/jsonschema-go v0.3.58 h1:OPixN4HW9H3FTh9BSomH2i0bdJi3V646TfSihzt9QBc=
github.com/swaggest/jsonschema-go v0.3.58/go.mod h1:5WFFGBBte5JAWAV8gDpNRJ/tlQnb1AHDdf/ghgsVUik=
github.com/swaggest/jsonschema-go v0.3.59 h1:BoPhtNvWbZRo1Wl6xvR3g6WL01COJTOAs6vMUnZgocM=
github.com/swaggest/jsonschema-go v0.3.59/go.mod h1:5WFFGBBte5JAWAV8gDpNRJ/tlQnb1AHDdf/ghgsVUik=
github.com/swaggest/openapi-go v0.2.39 h1:GfICsAAFnQuyxfywsGyCbPqDKeMXxots4N/9j6+qSCk=
github.com/swaggest/openapi-go v0.2.39/go.mod h1:g+AfRIkPCHdhqfW8zOD1Sk3PwLhxpWW8SNWHXrmA08c=
github.com/swaggest/refl v1.2.0/go.mod h1:CkC6g7h1PW33KprTuYRSw8UUOslRUt4lF3oe7tTIgNU=
Expand Down

0 comments on commit f483e1c

Please sign in to comment.