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
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"cb223aa9f88db46557ee5722f347055a69e0b3df",
"ed347a1958f584f2a891e15521cffe7aff754a62",
"b7a315c559cb457723c726c1b49f07c35f2bd8a9",
"9a38bf8d99187663fbb905e4aba0205735accf32"
"9a38bf8d99187663fbb905e4aba0205735accf32",
"15798b0700f9685e8dd3b7511de83c21e7acce02"
]
}
62 changes: 37 additions & 25 deletions dist/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10646,7 +10646,7 @@
]
}
},
"/api/v2/filters/keywords/{id}": {

Check warning on line 10649 in dist/schema.json

View workflow job for this annotation

GitHub Actions / test

no-ambiguous-paths

Paths should resolve unambiguously. Found two ambiguous paths: `/api/v2/filters/{filter_id}/keywords` and `/api/v2/filters/keywords/{id}`.
"get": {
"operationId": "getFiltersKeywordsByIdV2",
"summary": "View a single keyword",
Expand Down Expand Up @@ -11098,7 +11098,7 @@
]
}
},
"/api/v2/filters/statuses/{id}": {

Check warning on line 11101 in dist/schema.json

View workflow job for this annotation

GitHub Actions / test

no-ambiguous-paths

Paths should resolve unambiguously. Found two ambiguous paths: `/api/v2/filters/{filter_id}/keywords` and `/api/v2/filters/statuses/{id}`.
"get": {
"operationId": "getFiltersStatusesByIdV2",
"summary": "View a single status filter",
Expand Down Expand Up @@ -14981,7 +14981,7 @@
],
"responses": {
"200": {
"description": "Hash of timeline key and associated [Marker]",
"description": "Hash of String (Enumerable, anyOf `home` or `notifications`) key and associated [Marker] value",
"headers": {
"X-RateLimit-Limit": {
"description": "Number of requests permitted per time period",
Expand All @@ -15006,11 +15006,27 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Marker"
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/Marker"
},
"propertyNames": {
"enum": [
"home",
"notifications"
]
}
},
"examples": {
"Marker200Example": {
"$ref": "#/components/examples/Marker200Example"
"example": {
"notifications": {
"last_read_id": "35098814",
"version": 361,
"updated_at": "2019-11-26T22:37:25.239Z"
},
"home": {
"last_read_id": "103206604258487607",
"version": 468,
"updated_at": "2019-11-26T22:37:25.235Z"
}
}
}
Expand Down Expand Up @@ -15130,7 +15146,7 @@
],
"responses": {
"200": {
"description": "[Marker]",
"description": "Hash of String (Enumerable, anyOf `home` or `notifications`) key and associated [Marker] value",
"headers": {
"X-RateLimit-Limit": {
"description": "Number of requests permitted per time period",
Expand All @@ -15155,11 +15171,22 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Marker"
"type": "object",
"additionalProperties": {
"$ref": "#/components/schemas/Marker"
},
"propertyNames": {
"enum": [
"home",
"notifications"
]
}
},
"examples": {
"Marker200Example": {
"$ref": "#/components/examples/Marker200Example"
"example": {
"home": {
"last_read_id": "103194548672408537",
"version": 462,
"updated_at": "2019-11-24T19:39:39.337Z"
}
}
}
Expand Down Expand Up @@ -40332,21 +40359,6 @@
]
}
},
"Marker200Example": {
"summary": "Example for Marker",
"value": {
"notifications": {
"last_read_id": "35098814",
"version": 361,
"updated_at": "2019-11-26T22:37:25.239Z"
},
"home": {
"last_read_id": "103206604258487607",
"version": 468,
"updated_at": "2019-11-26T22:37:25.235Z"
}
}
},
"MediaAttachment200Example": {
"summary": "Example for MediaAttachment",
"value": {
Expand Down
36 changes: 36 additions & 0 deletions src/generators/TypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,42 @@ class TypeParser {
}
}

// Handle Hash with enumerable keys pattern:
// "Hash of String (Enumerable, anyOf `home` or `notifications`) key and associated [Entity] value"
const hashEnumMatch = returns.match(
/Hash of String \(Enumerable,\s*anyOf\s+([^)]+)\)\s+key and associated \[([^\]]+)\]/i
);
if (hashEnumMatch) {
const enumValuesStr = hashEnumMatch[1];
const entityName = hashEnumMatch[2];
const sanitizedEntityName =
this.utilityHelpers.sanitizeSchemaName(entityName);

// Extract enum values from backtick-quoted strings
const enumValues = enumValuesStr
.match(/`([^`]+)`/g)
?.map((val) => val.replace(/`/g, ''));

// Check if the entity exists in the components.schemas
if (spec.components?.schemas?.[sanitizedEntityName]) {
const schema: OpenAPIProperty = {
type: 'object',
additionalProperties: {
$ref: `#/components/schemas/${sanitizedEntityName}`,
},
};

// Add propertyNames constraint with enum if we found enum values
if (enumValues && enumValues.length > 0) {
schema.propertyNames = {
enum: enumValues,
};
}

return schema;
}
}

// Handle array responses: "Array of String", "Array of Integer", etc.
const basicArrayMatch = returns.match(/Array of (\w+)/i);
if (basicArrayMatch) {
Expand Down
3 changes: 3 additions & 0 deletions src/interfaces/OpenAPISchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ interface OpenAPIProperty {
required?: string[];
example?: any;
additionalProperties?: OpenAPIProperty | boolean;
propertyNames?: {
enum?: string[];
};
}

interface OpenAPISchema {
Expand Down