Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/cli/scripts/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const isAlreadyPublished = Effect.fnUntraced(function* (
name: string,
version: string,
) {
const encodedName = name.replace("/", "%2F");
const encodedName = name.replaceAll("/", "%2F");
const res = yield* HttpClient.get(`${registryUrl}/${encodedName}/${version}`);
if (res.status === 200) return true;
if (res.status === 404) return false;
Expand Down
7 changes: 7 additions & 0 deletions packages/api/scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ const UUID_PATTERN =
// Keys stripped from a schema node because they describe documentation/example
// values, not the value's shape.
const SCHEMA_METADATA_KEYS = new Set(["default", "example", "examples"]);
const CONTENT_ANNOTATION_KEYS = new Set(["contentEncoding", "contentMediaType"]);

// `inPropertiesMap` tracks whether the current object is the value of a
// `properties: {...}` map; there, keys are user-defined property names (which may
Expand Down Expand Up @@ -271,6 +272,12 @@ export function sanitizeOpenApiSchema(
continue;
}

// The OpenAPI 3.0 converter rejects the annotation-only content keywords; `format` still
// carries the encoding.
if (!inPropertiesMap && CONTENT_ANNOTATION_KEYS.has(key)) {
continue;
}

// The OpenAPI 3.0 converter rejects `const`; a one-value `enum` is equivalent.
if (!inPropertiesMap && key === "const") {
Object.assign(sanitized, { enum: [rawValue] });
Expand Down
15 changes: 15 additions & 0 deletions packages/api/scripts/generate.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ describe("generate", () => {
});
});

test("drops content annotations from binary strings without touching a property named contentEncoding", () => {
expect(
renderOpenApiSchema({
type: "object",
additionalProperties: false,
properties: {
eszip: { type: "string", format: "binary", contentEncoding: "binary" },
contentEncoding: { type: "string", contentMediaType: "text/plain" },
},
}),
).toBe(
'Schema.Struct({ "eszip": Schema.optionalKey(Schema.String.annotate({ "format": "binary" })), "contentEncoding": Schema.optionalKey(Schema.String) })',
);
});

test("widens multi-value string enums and keeps single-value discriminators closed", () => {
expect(
openStringEnums({
Expand Down
Loading