Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference in callback #753

Closed
ShouheiNishi opened this issue Jan 26, 2023 · 1 comment · Fixed by #757
Closed

Reference in callback #753

ShouheiNishi opened this issue Jan 26, 2023 · 1 comment · Fixed by #757

Comments

@ShouheiNishi
Copy link
Contributor

If multiple callback objects with same expression are exist, reference in some of these are not resolved by the loader.

package openapi3_test

import (
        "testing"

        "github.com/stretchr/testify/require"

        "github.com/getkin/kin-openapi/openapi3"
)

func TestXXX(t *testing.T) {

        loader := openapi3.NewLoader()

        doc, err := loader.LoadFromFile("testdata/issueNEW.yaml")
        require.NoError(t, err)

        err = doc.Validate(loader.Context)
        require.NoError(t, err)

        require.NotNil(t, (*doc.Paths["/test1"].Post.Callbacks["callback1"].Value)["{request.body#/callback}"].Post.RequestBody.Value.Content["application/json"].Schema.Value)
        require.NotNil(t, (*doc.Paths["/test2"].Post.Callbacks["callback2"].Value)["{request.body#/callback}"].Post.RequestBody.Value.Content["application/json"].Schema.Value)
}
openapi: 3.0.0
info:
  version: 0.0.1
  title: 'test'
paths:
  /test1:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: 'test'
      callbacks:
        callback1:
          '{request.body#/callback}':
            post:
              requestBody:
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/test'
              responses:
                '200':
                  description: 'test'
  /test2:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: 'test'
      callbacks:
        callback2:
          '{request.body#/callback}':
            post:
              requestBody:
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/test'
              responses:
                '200':
                  description: 'test'
components:
  schemas:
    test:
      type: string
fenollp added a commit to fenollp/kin-openapi that referenced this issue Jan 30, 2023
Signed-off-by: Pierre Fenoll <[email protected]>
@fenollp
Copy link
Collaborator

fenollp commented Jan 30, 2023

Note I've opened #756
I corrected '{request.body#/callback}' to '{$request.body#/callback}' (leading $) but the issue is still present (more: visiting order is not deterministic. cc #695 )

More investigation needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants