I've been trying to work with the Riot API, (openapi schema here: http://www.mingweisamuel.com/riotapi-schema/openapi-3.0.0.json) and found that not only method names generated by typegen weren't escaped properly (ie #26) but also typegen could not assign proper types to each method.
I found that the dtsgenerator dependency sanitizes/normalizes operation id names when parsing schema to path names so path names for operations are not the same anymore, and thus cant be found by typegen.
Example:
"tft-league-v1.getLeagueEntriesForSummoner" is sanitized as "tft_league_v1.getLeagueEntriesForSummoner"
So when typegen does a filter for the param paths on an operation, there are no results.
A fix would be to do the same transformation on operationId when searching for types.
Solution:
// on src/typegen/typegen.ts
import {normalizeTypeName} from "@anttiviljami/dtsgenerator/dist/core/typeNameConvertor"
// normalized operationId
const normalizedOpId = normalizeTypeName(operationId)
// parameters arg
const parameterTypePaths = _.chain([
_.find(exportTypes, { schemaRef: `#/paths/${normalizedOpId}/pathParameters` }),
_.find(exportTypes, { schemaRef: `#/paths/${normalizedOpId}/queryParameters` }),
_.find(exportTypes, { schemaRef: `#/paths/${normalizedOpId}/headerParameters` }),
_.find(exportTypes, { schemaRef: `#/paths/${normalizedOpId}/cookieParameters` }),
])
.filter()
.map('path')
.value();
// and similar transformation for request body type and response type
I've been trying to work with the Riot API, (openapi schema here: http://www.mingweisamuel.com/riotapi-schema/openapi-3.0.0.json) and found that not only method names generated by typegen weren't escaped properly (ie #26) but also typegen could not assign proper types to each method.
I found that the dtsgenerator dependency sanitizes/normalizes operation id names when parsing schema to path names so path names for operations are not the same anymore, and thus cant be found by typegen.
Example: "tft-league-v1.getLeagueEntriesForSummoner" is sanitized as "tft_league_v1.getLeagueEntriesForSummoner"
So when typegen does a filter for the param paths on an operation, there are no results.
A fix would be to do the same transformation on operationId when searching for types.
Solution: