Skip to content

Commit

Permalink
feat(specs): add dictionary specs (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts authored Dec 28, 2021
1 parent 4bacf25 commit 6587e94
Show file tree
Hide file tree
Showing 75 changed files with 7,767 additions and 1,549 deletions.
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,27 @@ yarn docker:clean

## Contributing

You can now make changes locally and run commands through the docker container.
You can make changes locally and run commands through the docker container.

### Build and validate specs

#### Usage

```bash
yarn docker build:specs <client | all>
```

#### Build all specs

```bash
yarn docker build:specs
```

#### Build specific spec

```bash
yarn docker build:specs recommend
```

### Generate clients based on the [`specs`](./specs/)

Expand Down Expand Up @@ -78,18 +98,24 @@ yarn docker build:clients java recommend

The clients can be tested inside the [`playground`](./playground) folder

## Usage
### Usage

```bash
yarn docker playground:<language>:<client>
```

## JavaScript
### JavaScript

```bash
yarn docker playground:js:search
```

### Java

```bash
yarn docker playground:java:search
```

# Troubleshooting

> `Error: The operation couldn’t be completed. Unable to locate a Java Runtime.`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.algolia.model;

import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

/**
* Whether the pattern parameter must match the beginning or the end of the query string, or both,
* or none.
*/
@JsonAdapter(Anchoring.Adapter.class)
public enum Anchoring {
IS("is"),

STARTSWITH("startsWith"),

ENDSWITH("endsWith"),

CONTAINS("contains");

private String value;

Anchoring(String value) {
this.value = value;
}

public String getValue() {
return value;
}

@Override
public String toString() {
return String.valueOf(value);
}

public static Anchoring fromValue(String value) {
for (Anchoring b : Anchoring.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}

public static class Adapter extends TypeAdapter<Anchoring> {

@Override
public void write(final JsonWriter jsonWriter, final Anchoring enumeration)
throws IOException {
jsonWriter.value(enumeration.getValue());
}

@Override
public Anchoring read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return Anchoring.fromValue(value);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package com.algolia.model;

import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Objects;

/** Automatic facet Filter. */
@ApiModel(description = "Automatic facet Filter.")
public class AutomaticFacetFilter {

public static final String SERIALIZED_NAME_FACET = "facet";

@SerializedName(SERIALIZED_NAME_FACET)
private String facet;

public static final String SERIALIZED_NAME_SCORE = "score";

@SerializedName(SERIALIZED_NAME_SCORE)
private Integer score = 1;

public static final String SERIALIZED_NAME_DISJUNCTIVE = "disjunctive";

@SerializedName(SERIALIZED_NAME_DISJUNCTIVE)
private Boolean disjunctive = false;

public AutomaticFacetFilter facet(String facet) {
this.facet = facet;
return this;
}

/**
* Attribute to filter on. This must match a facet placeholder in the Rule's pattern.
*
* @return facet
*/
@javax.annotation.Nonnull
@ApiModelProperty(
required = true,
value = "Attribute to filter on. This must match a facet placeholder in the Rule's pattern."
)
public String getFacet() {
return facet;
}

public void setFacet(String facet) {
this.facet = facet;
}

public AutomaticFacetFilter score(Integer score) {
this.score = score;
return this;
}

/**
* Score for the filter. Typically used for optional or disjunctive filters.
*
* @return score
*/
@javax.annotation.Nullable
@ApiModelProperty(
value = "Score for the filter. Typically used for optional or disjunctive filters."
)
public Integer getScore() {
return score;
}

public void setScore(Integer score) {
this.score = score;
}

public AutomaticFacetFilter disjunctive(Boolean disjunctive) {
this.disjunctive = disjunctive;
return this;
}

/**
* Whether the filter is disjunctive (true) or conjunctive (false).
*
* @return disjunctive
*/
@javax.annotation.Nullable
@ApiModelProperty(
value = "Whether the filter is disjunctive (true) or conjunctive (false)."
)
public Boolean getDisjunctive() {
return disjunctive;
}

public void setDisjunctive(Boolean disjunctive) {
this.disjunctive = disjunctive;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AutomaticFacetFilter automaticFacetFilter = (AutomaticFacetFilter) o;
return (
Objects.equals(this.facet, automaticFacetFilter.facet) &&
Objects.equals(this.score, automaticFacetFilter.score) &&
Objects.equals(this.disjunctive, automaticFacetFilter.disjunctive)
);
}

@Override
public int hashCode() {
return Objects.hash(facet, score, disjunctive);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class AutomaticFacetFilter {\n");
sb.append(" facet: ").append(toIndentedString(facet)).append("\n");
sb.append(" score: ").append(toIndentedString(score)).append("\n");
sb
.append(" disjunctive: ")
.append(toIndentedString(disjunctive))
.append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -578,14 +578,14 @@ public BaseSearchParams aroundLatLngViaIP(Boolean aroundLatLngViaIP) {
}

/**
* Search for entries around a given location automatically computed from the requesters IP
* Search for entries around a given location automatically computed from the requester's IP
* address.
*
* @return aroundLatLngViaIP
*/
@javax.annotation.Nullable
@ApiModelProperty(
value = "Search for entries around a given location automatically computed from the requesters" +
value = "Search for entries around a given location automatically computed from the requester's" +
" IP address."
)
public Boolean getAroundLatLngViaIP() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,15 @@ public BaseSearchResponse indexUsed(String indexUsed) {
}

/**
* Index name used for the query. In the case of an A/B test, the targeted index isnt always the
* Index name used for the query. In the case of an A/B test, the targeted index isn't always the
* index used by the query.
*
* @return indexUsed
*/
@javax.annotation.Nullable
@ApiModelProperty(
example = "indexNameAlt",
value = "Index name used for the query. In the case of an A/B test, the targeted index isnt" +
value = "Index name used for the query. In the case of an A/B test, the targeted index isn't" +
" always the index used by the query."
)
public String getIndexUsed() {
Expand Down
Loading

0 comments on commit 6587e94

Please sign in to comment.