Skip to content
Discussion options

You must be logged in to vote

Hello, please check a test for an example: https://github.com/swaggest/openapi-go/blob/v0.2.53/openapi3/reflect_test.go#L1213.
(And also upgrade to latest version, since there was a bug that discarded manual changes like this)

func TestNewReflector_examples(t *testing.T) {
	r := openapi3.NewReflector()

	op, err := r.NewOperationContext(http.MethodGet, "/")
	require.NoError(t, err)

	type O1 struct {
		F1   int    `json:"f1,omitempty"`
		Code string `json:"code"`
	}

	type O2 struct {
		F2   int    `json:"f2,omitempty"`
		Code string `json:"code"`
	}

	st := http.StatusCreated

	op.AddRespStructure(jsonschema.OneOf(O1{}, O2{}), func(cu *openapi.ContentUnit) {
		cu.HTTPStatus = st
	})

	if o3

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@chrsvl
Comment options

Answer selected by chrsvl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants