Skip to content

Commit

Permalink
Merge pull request #38 from clerk/speakeasy-sdk-regen-1731969931
Browse files Browse the repository at this point in the history
chore: 🐝 Update SDK - Generate 1.3.0
  • Loading branch information
speakeasybot authored Nov 18, 2024
2 parents 939aab4 + a4212fe commit 7c9243f
Show file tree
Hide file tree
Showing 15 changed files with 335 additions and 96 deletions.
12 changes: 7 additions & 5 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ id: 1d22a5a4-8bac-42e3-b164-121fcacf66c9
management:
docChecksum: b7d2d41694154c8bb06badd95ee5eabf
docVersion: v1
speakeasyVersion: 1.437.0
generationVersion: 2.456.0
releaseVersion: 1.2.0
configChecksum: 09ed2850809d9e84b4ae26784404d320
speakeasyVersion: 1.441.0
generationVersion: 2.460.1
releaseVersion: 1.3.0
configChecksum: 97544bded64ebb467d8148b7b71880ba
repoURL: https://github.com/clerk/clerk-sdk-java.git
published: true
features:
java:
additionalDependencies: 0.1.0
additionalProperties: 0.0.1
constsAndDefaults: 0.1.1
core: 3.31.0
core: 3.32.0
deprecations: 2.81.1
examples: 2.81.3
flattening: 2.81.1
Expand Down Expand Up @@ -1234,6 +1234,7 @@ generatedFiles:
- src/main/java/com/clerk/backend_api/utils/OneOfDeserializer.java
- src/main/java/com/clerk/backend_api/utils/Options.java
- src/main/java/com/clerk/backend_api/utils/PathParamsMetadata.java
- src/main/java/com/clerk/backend_api/utils/QueryParameter.java
- src/main/java/com/clerk/backend_api/utils/QueryParameters.java
- src/main/java/com/clerk/backend_api/utils/QueryParamsMetadata.java
- src/main/java/com/clerk/backend_api/utils/RequestBody.java
Expand All @@ -1248,6 +1249,7 @@ generatedFiles:
- src/main/java/com/clerk/backend_api/utils/SpeakeasyMetadata.java
- src/main/java/com/clerk/backend_api/utils/TypedObject.java
- src/main/java/com/clerk/backend_api/utils/Types.java
- src/main/java/com/clerk/backend_api/utils/Utf8UrlEncoder.java
- src/main/java/com/clerk/backend_api/utils/Utils.java
examples:
GetPublicInterstitial: {}
Expand Down
2 changes: 1 addition & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ generation:
oAuth2ClientCredentialsEnabled: true
oAuth2PasswordEnabled: false
java:
version: 1.2.0
version: 1.3.0
additionalDependencies: []
additionalPlugins: []
artifactID: backend-api
Expand Down
10 changes: 5 additions & 5 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
speakeasyVersion: 1.437.0
speakeasyVersion: 1.441.0
sources:
clerk-java-sdk:
sourceNamespace: clerk-java-sdk
sourceRevisionDigest: sha256:1a486565939833e7da8fd89f4dca29e4ca17f28654e44085a3363f0f1e440eeb
sourceRevisionDigest: sha256:5bfc2dc2bdbf8afca23882fdc2fc99541c6aa384f8ea99311727bdc12bbe0c3f
sourceBlobDigest: sha256:3a79bd76a35cec51d82efcdad7c5fffff14db6ed394011e299ac78c2f6159e12
tags:
- latest
- main
- speakeasy-sdk-regen-1731969931
targets:
clerk-java:
source: clerk-java-sdk
sourceNamespace: clerk-java-sdk
sourceRevisionDigest: sha256:1a486565939833e7da8fd89f4dca29e4ca17f28654e44085a3363f0f1e440eeb
sourceRevisionDigest: sha256:5bfc2dc2bdbf8afca23882fdc2fc99541c6aa384f8ea99311727bdc12bbe0c3f
sourceBlobDigest: sha256:3a79bd76a35cec51d82efcdad7c5fffff14db6ed394011e299ac78c2f6159e12
codeSamplesNamespace: clerk-java-sdk-code-samples
codeSamplesRevisionDigest: sha256:d767573120892d3ab715b3145a54847f35113612c3817bacc394d4b02e93896d
codeSamplesRevisionDigest: sha256:d1becf6d0bfef998549a0d7e2547800a0c78a3b2fa6d8e625537c69afec6d8b1
my-first-target:
source: clerk-java-sdk
sourceNamespace: clerk-java-sdk
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ The samples below show how a published SDK artifact is used:

Gradle:
```groovy
implementation 'com.clerk:backend-api:1.2.0'
implementation 'com.clerk:backend-api:1.3.0'
```

Maven:
```xml
<dependency>
<groupId>com.clerk</groupId>
<artifactId>backend-api</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
</dependency>
```

Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,14 @@ Based on:
### Generated
- [java v1.2.0] .
### Releases
- [Maven Central v1.2.0] https://central.sonatype.com/artifact/com.clerk/backend-api/1.2.0 - .
- [Maven Central v1.2.0] https://central.sonatype.com/artifact/com.clerk/backend-api/1.2.0 - .

## 2024-11-18 22:45:28
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.441.0 (2.460.1) https://github.com/speakeasy-api/speakeasy
### Generated
- [java v1.3.0] .
### Releases
- [Maven Central v1.3.0] https://central.sonatype.com/artifact/com.clerk/backend-api/1.3.0 - .
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ tasks.withType(Javadoc) {
}

group = "com.clerk"
version = "1.2.0"
version = "1.3.0"

sourcesJar {
archiveBaseName = "backend-api"
Expand Down Expand Up @@ -101,7 +101,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.clerk'
artifactId = 'backend-api'
version = '1.2.0'
version = '1.3.0'

from components.java

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/clerk/backend_api/SDKConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public Optional<SecuritySource> securitySource() {
public int serverIdx = 0;
private static final String LANGUAGE = "java";
public static final String OPENAPI_DOC_VERSION = "v1";
public static final String SDK_VERSION = "1.2.0";
public static final String GEN_VERSION = "2.456.0";
public static final String SDK_VERSION = "1.3.0";
public static final String GEN_VERSION = "2.460.1";
private static final String BASE_PACKAGE = "com.clerk.backend_api";
public static final String USER_AGENT =
String.format("speakeasy-sdk/%s %s %s %s %s",
Expand Down
68 changes: 52 additions & 16 deletions src/main/java/com/clerk/backend_api/utils/HTTPRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package com.clerk.backend_api.utils;

import java.net.URI;
import java.net.URISyntaxException;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublisher;
Expand All @@ -15,15 +16,15 @@
import java.util.Map;
import java.util.Optional;

import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.message.BasicNameValuePair;

public class HTTPRequest {

private static final String FRAGMENT_SEGMENT_START = "#";
private static final String QUERY_NAME_VALUE_DELIMITER = "=";
private static final String QUERY_PARAMETER_DELIMITER = "&";
private static final String QUERY_SEGMENT_START = "?";
private final String baseURL;
private final String method;
private final List<NameValuePair> queryParams = new ArrayList<>();
private final List<QueryParameter> queryParams = new ArrayList<>();
private final Map<String, List<String>> headers = new HashMap<>();
private Optional<SerializedBody> body = Optional.empty(); // mutable

Expand Down Expand Up @@ -54,21 +55,21 @@ public HTTPRequest addHeaders(Map<String, List<String>> map) {
return this;
}

public HTTPRequest addQueryParam(String name, String value) {
addQueryParam(new BasicNameValuePair(name, value));
public HTTPRequest addQueryParam(QueryParameter param) {
this.queryParams.add(param);
return this;
}

public HTTPRequest addQueryParam(NameValuePair param) {
this.queryParams.add(param);
public HTTPRequest addQueryParam(String key, String value, boolean allowReserved) {
this.queryParams.add(QueryParameter.of(key, value, allowReserved));
return this;
}

public HTTPRequest addQueryParams(Collection<NameValuePair> params) {
public HTTPRequest addQueryParams(Collection<QueryParameter> params) {
params.forEach(p -> addQueryParam(p));
return this;
}

public HttpRequest build() {
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder();

Expand All @@ -81,14 +82,49 @@ public HttpRequest build() {
}
requestBuilder.method(method, bodyPublisher);
try {
URIBuilder b = new URIBuilder(this.baseURL);
queryParams.forEach(pair -> b.addParameter(pair.getName(), pair.getValue()));
requestBuilder.uri(b.build());
requestBuilder.uri(new URI(buildUrl(baseURL, queryParams)));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
headers.forEach((k, list) -> list.forEach(v -> requestBuilder.header(k, v)));
return requestBuilder.build();
}


// VisibleForTesting
public static String buildUrl(String baseURL, Collection<QueryParameter> queryParams) {
if (queryParams.isEmpty()) {
return baseURL;
} else {
final String base;
final String fragment;
int i = baseURL.indexOf(FRAGMENT_SEGMENT_START);
if (i == -1) {
base = baseURL;
fragment = "";
} else {
base = baseURL.substring(0, i);
fragment = baseURL.substring(i);
}
StringBuilder b = new StringBuilder(base);
if (!base.contains(QUERY_SEGMENT_START)) {
b.append(QUERY_SEGMENT_START);
} else {
b.append(QUERY_PARAMETER_DELIMITER);
}
boolean first = true;
for (QueryParameter p : queryParams) {
if (!first) {
b.append(QUERY_PARAMETER_DELIMITER);
}
first = false;
// don't allow reserved characters to be unencoded in key (??)
b.append(Utf8UrlEncoder.DEFAULT.encode(p.name()));
b.append(QUERY_NAME_VALUE_DELIMITER);
b.append(Utf8UrlEncoder.allowReserved(p.allowReserved()).encode(p.value()));
}
b.append(fragment);
return b.toString();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@

class PathParamsMetadata {

// these fields set via reflection

String style = "simple";
boolean explode;
String name;
String serialization;
boolean allowReserved;

private PathParamsMetadata() {
}

// pathParam:style=simple,explode=false,name=apiID
static PathParamsMetadata parse(Field field) throws IllegalArgumentException, IllegalAccessException {
return Metadata.parse("pathParam", new PathParamsMetadata(), field);
}
Expand Down
62 changes: 62 additions & 0 deletions src/main/java/com/clerk/backend_api/utils/QueryParameter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/

package com.clerk.backend_api.utils;

import java.util.Objects;

// internal class, not for public use
// TODO move to internal package
public final class QueryParameter {

private final String name;
private final String value;
private final boolean allowReserved;

private QueryParameter(String name, String value, boolean allowReserved) {
this.name = name;
this.value = value;
this.allowReserved = allowReserved;
}

public static QueryParameter of(String name, String value, boolean allowReserved) {
return new QueryParameter(name, value, allowReserved);
}

public String name() {
return name;
}

public String value() {
return value;
}

public boolean allowReserved() {
return allowReserved;
}

@Override
public String toString() {
return "QueryParameter [name=" + name + ", value=" + value + ", allowReserved=" + allowReserved + "]";
}

@Override
public int hashCode() {
return Objects.hash(allowReserved, name, value);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
QueryParameter other = (QueryParameter) obj;
return allowReserved == other.allowReserved && Objects.equals(name, other.name)
&& Objects.equals(value, other.value);
}

}
Loading

0 comments on commit 7c9243f

Please sign in to comment.