Skip to content

Conversation

@jgowdyelastic
Copy link
Member

Adding request and response examples for our public saved object APIs

@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!

Copy link
Contributor

@szabosteve szabosteve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive by comment

},
},
options: {
oasOperationObject: () => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Nice work @jgowdyelastic ! Minor suggestion: factorizing these examples into another file might keep the flow of your route definition a bit slimmer. Also, using TypeScript, you can check that value matches what your code returns. Up to you!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this for yml files rather than inline JSON

Copy link
Member Author

@jgowdyelastic jgowdyelastic Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing this locally, I'm getting this error for the saved_objects/sync endpoint:

   │      /paths/~1api~1ml~1saved_objects~1sync/get/responses/401/content/application~1json
   │      must have required property 'examples'
   │      Failed check @ schema path: #/required

I've no idea what I'm missing, the yml file contains examples.

I've tried updating the yml file to contain a 401 section, but I'm still getting the error:

responses:
  '200':
    content:
      application/json:
        examples:
          successSyncResponse:
            value:
              savedObjectsCreated:
                'anomaly-detector':
                  'test-job':
                    success: true
              savedObjectsDeleted: {}
              datafeedsAdded: {}
              datafeedsRemoved: {}
  '401':
    content:
      application/json:
        examples:
          failedSyncResponse:
            value:
              'statusCode': 401
              'error': 'Unauthorized'
              'message': "[security_exception\n\tRoot causes:\n\t\tsecurity_exception: unable to authenticate user [test] for REST request [/_security/_authenticate]]: unable to authenticate user [test] for REST request [/_security/_authenticate]"

I also have no idea why this endpoint requires a 401 section when the others do not?

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 this pull request may close these issues.

4 participants