-
Notifications
You must be signed in to change notification settings - Fork 91
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
Adds examples to schema.json and OpenAPI outputs #3737
Conversation
compiler/src/model/metamodel.ts
Outdated
value?: string | ||
external_value?: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add doc-comments explaining what these are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment above the class references the OpenAPI spec page which fully explains the fields.
let mut openapi_examples = indexmap! {}; | ||
for (name, schema_example) in schema_examples { | ||
let openapi_example = Example { | ||
value: Some(json!(schema_example.value)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will output the example as a JSON string, e.g. "value": "{\"foo\":\"bar\"}"
instead of "value": {"foo": "bar"}
.
Is this what we want? The OpenAPI spec shows that this should be a value and not a value-in-a-string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a docs point of view, it doesn't seem to matter. For example when I run our current overlays, I get both variations and they both publish fine. For example:
"ClusterPutComponentTemplateRequestExample1": {
"summary": "Create a template",
"value": {
"template": null,
"settings": {
"number_of_shards": 1
}...
as well as:
"ClosePointInTimeResponseExample1": {
"description": "A successful response from `DELETE /_pit`.",
"value": "{\n \"succeeded\": true, \n \"num_freed\": 3 \n}"
},
If one of these is preferable from a client point of view, that would be good to know. Otherwise from a docs point of view I'm good with whatever is easiest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the example files, I commonly saw JSON strings, but there were also instances of YAML objects. For consistency, I have converted everything to JSON strings.
7689d65
to
ba16216
Compare
I've rebased and marked the resolved comments... I think this is ready for re-evaluation |
…PI request and response examples. It then adds the 'examples' info to schema.json and to the OpenAPI JSON files.
Co-authored-by: Sylvain Wallez <sylvain@elastic.co>
Co-authored-by: Sylvain Wallez <sylvain@elastic.co>
17dfe3e
to
b594e24
Compare
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-8.x 8.x
# Navigate to the new working tree
cd .worktrees/backport-8.x
# Create a new branch
git switch --create backport-3737-to-8.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 e9bc80f1c92fcfa3dd2dae3deb87177b0855e35a
# Push it to GitHub
git push --set-upstream origin backport-3737-to-8.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-8.x Then, create a pull request where the |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-8.18 8.18
# Navigate to the new working tree
cd .worktrees/backport-8.18
# Create a new branch
git switch --create backport-3737-to-8.18
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 e9bc80f1c92fcfa3dd2dae3deb87177b0855e35a
# Push it to GitHub
git push --set-upstream origin backport-3737-to-8.18
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-8.18 Then, create a pull request where the |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-9.0 9.0
# Navigate to the new working tree
cd .worktrees/backport-9.0
# Create a new branch
git switch --create backport-3737-to-9.0
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 e9bc80f1c92fcfa3dd2dae3deb87177b0855e35a
# Push it to GitHub
git push --set-upstream origin backport-3737-to-9.0
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-9.0 Then, create a pull request where the |
* This featre scans All the API folders in the specfication to locate API request and response examples. It then adds the 'examples' info to schema.json and to the OpenAPI JSON files. --------- Co-authored-by: Lisa Cawley <lcawley@elastic.co> Co-authored-by: Sylvain Wallez <sylvain@elastic.co>
* This featre scans All the API folders in the specfication to locate API request and response examples. It then adds the 'examples' info to schema.json and to the OpenAPI JSON files. --------- Co-authored-by: Lisa Cawley <lcawley@elastic.co> Co-authored-by: Sylvain Wallez <sylvain@elastic.co>
* This featre scans All the API folders in the specfication to locate API request and response examples. It then adds the 'examples' info to schema.json and to the OpenAPI JSON files. --------- Co-authored-by: Siamak Poursabahian <siamak.poursabahian@elastic.co> Co-authored-by: Lisa Cawley <lcawley@elastic.co>
* This featre scans All the API folders in the specfication to locate API request and response examples. It then adds the 'examples' info to schema.json and to the OpenAPI JSON files. --------- Co-authored-by: Lisa Cawley <lcawley@elastic.co> Co-authored-by: Sylvain Wallez <sylvain@elastic.co>
* This featre scans All the API folders in the specfication to locate API request and response examples. It then adds the 'examples' info to schema.json and to the OpenAPI JSON files. --------- Co-authored-by: Siamak Poursabahian <siamak.poursabahian@elastic.co> Co-authored-by: Lisa Cawley <lcawley@elastic.co>
* This featre scans All the API folders in the specfication to locate API request and response examples. It then adds the 'examples' info to schema.json and to the OpenAPI JSON files. --------- Co-authored-by: Siamak Poursabahian <siamak.poursabahian@elastic.co> Co-authored-by: Lisa Cawley <lcawley@elastic.co>
This feature scans All the API folders in the specification to locate API request and response examples. It then adds the 'examples' info to schema.json and to the OpenAPI JSON files.