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

Add Synonyms API spec #2210

Merged
merged 13 commits into from
Jul 28, 2023
Merged

Add Synonyms API spec #2210

merged 13 commits into from
Jul 28, 2023

Conversation

carlosdelest
Copy link
Member

Adds Synonyms API spec and types

@carlosdelest carlosdelest marked this pull request as ready for review July 27, 2023 06:54
@carlosdelest carlosdelest requested a review from a team as a code owner July 27, 2023 06:54
@@ -5,8 +5,7 @@
"description": "Creates or updates a synonyms set"
},
"stability": "experimental",
"visibility": "feature_flag",
"feature_flag": "es.synonyms_feature_flag_enabled",
"visibility": "public",
Copy link
Member Author

Choose a reason for hiding this comment

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

Feature flags were removed per elastic/elasticsearch#97962


export type SynonymString = string

export class SynonymRuleOptionalId {
Copy link
Member Author

Choose a reason for hiding this comment

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

There are operations (PUT) that don't need an ID to be included, so it will be generated by the API. I wanted to use a strict type for that, but it might be overkill...

Copy link
Member

Choose a reason for hiding this comment

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

My two cents: I don't think it hurts, but I'm not sure what it adds. Happy to leave it in but I don't have strong feelings either way.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think its fine, I understand the intent clearly enough and it will allow some clients to have validation for mandatory fields which is great.

As a nit, maybe I'd add a comment only for the spec with // to highlight why this is like this. Comments in form /**/ are included in the generated schema and the clients, // are not.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @Anaethelion - I added comments to clarify why they're used 👍


import { SynonymRule, SynonymRuleOptionalId } from './SynonymRule'

export class SynonymsSetUpdate {
Copy link
Member Author

Choose a reason for hiding this comment

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

Same here, happy to hear thoughts on using specific types for including ids or not

Copy link
Member

@kderusso kderusso left a comment

Choose a reason for hiding this comment

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

LGTM with a couple of comments

},
"stability": "experimental",
"visibility": "public",
"feature_flag": "es.synonyms_api_feature_flag_enabled",
Copy link
Member

Choose a reason for hiding this comment

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

I think we want to remove the FF from this file

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, thanks for the catch! 👍


import { SynonymsUpdateResult } from '../../synonyms/_types/SynonymsUpdateResult'

export class Response {
Copy link
Member

Choose a reason for hiding this comment

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

There's some duplication between this response signature and others such as SynonymRuleDeleteResponse. Is this intentional or is there any way to consolidate?

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 tried to consolidate as much as possible by creating the SynonymsUpdateResult type, which is essentially the body for these responses.

I'd say we need the separate Request / Response classes for the codegen to work - hopefully the clients team can recommend a better pattern here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say we need the separate Request / Response classes for the codegen to work - hopefully the clients team can recommend a better pattern here.

Yes we need those for codegen, each request/response couple will be generated into specific expanded types with their namespace.
In this case it does seem like there's duplication but I don't have a better pattern, you went as far as we can at the moment.

Kudos for a consistent API! 👍

*/
from?: integer
/**
* specifies a max number of results to get
Copy link
Member

Choose a reason for hiding this comment

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

Should we include the default in the comment here too for consistency?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure! Thanks for the suggestion


export type SynonymString = string

export class SynonymRuleOptionalId {
Copy link
Member

Choose a reason for hiding this comment

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

My two cents: I don't think it hurts, but I'm not sure what it adds. Happy to leave it in but I don't have strong feelings either way.

Copy link
Contributor

@Anaethelion Anaethelion left a comment

Choose a reason for hiding this comment

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

LGTM, left a comment to add some internal comments for types.

@carlosdelest carlosdelest enabled auto-merge (squash) July 28, 2023 16:35
@github-actions
Copy link
Contributor

Following you can find the validation results for the APIs you have changed.

API Status Request Response
synonym_rule.delete Missing test Missing test
synonym_rule.get Missing test Missing test
synonym_rule.put Missing test Missing test
synonyms.delete Missing test Missing test
synonyms.get Missing test Missing test
synonyms.put Missing test Missing test
synonyms_sets.get Missing test Missing test

You can validate these APIs yourself by using the make validate target.

@carlosdelest carlosdelest merged commit ea5c81f into main Jul 28, 2023
5 checks passed
@carlosdelest carlosdelest deleted the carlosdelest/synonyms-api-spec branch July 28, 2023 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants