-
-
Notifications
You must be signed in to change notification settings - Fork 281
Open
Labels
bug 🔥Broken or incorrect behavior.Broken or incorrect behavior.
Description
Description
First time trying out this generator! I appreciate the great set-up instructions. My spec contains a type that uses propertyNames. I saw that this is supported (#2279) but a seemingly random array _heyapi_190_ is in the generated code instead of the enum. Do I need to use a specific plugin in order to see the enum?
Spec input file
"objectTypes": {
"type": "object",
"additionalProperties": {
"type": "number",
"format": "double"
},
"example": {
"objectType1": 1,
"objectType2": 0.5
},
"propertyNames": {
"$ref": "#components/schemas/ObjectType",
"enum": [
"OBJECT_TYPE1",
"OBJECT_TYPE2",
]
}
},
"ObjectType": {
"$ref": "#components/schemas/ObjectType",
"enum": [
"OBJECT_TYPE1",
"OBJECT_TYPE2",
]
}
Generated code in schemas.gen.ts
objectTypes: {
type: 'object',
additionalProperties: {
type: 'number',
format: 'double',
},
propertyNames: {
$ref: '#components/schemas/ObjectType',
enum: [
'OBJECT_TYPE1',
'OBJECT_TYPE2',
],
},
},
export const ObjectTypeSchema = {
$ref: '#components/schemas/ObjectType',
enum: [
'OBJECT_TYPE1',
'OBJECT_TYPE2',
],
} as const;
Output in types.gen.ts after running pnpm run openapi-ts
objectTypes?: {
[key in _heyapi_190_]?: number;
};
Expected correct output
objectTypes?: {
[key in ObjectType]?: number;
};
Reproducible example or configuration
The config file comes from the Hey-api Stackblitz example:
https://stackblitz.com/edit/hey-api-client-fetch-example?file=openapi-ts.config.ts
package.json
"scripts": {"openapi-ts": "openapi-ts",}
openapi-ts.config.ts
const auth = {
username: the_username,
password: the_password,
};
const credentials = Buffer.from(`${auth.username}:${auth.password}`).toString('base64');
export default defineConfig({
input: {
path: 'https://our-spec-url',
fetch: {
headers: {
Authorization: `Basic ${credentials}`,
},
},
},
output: {
format: 'prettier',
lint: 'eslint',
path: 'openapiV31/src/client',
},
plugins: [
'@hey-api/schemas',
{
dates: true,
name: '@hey-api/transformers',
},
{
enums: 'javascript',
name: '@hey-api/typescript',
},
{
name: '@hey-api/sdk',
transformer: true,
},
],
});
OpenAPI specification (optional)
"objectTypes": {
"type": "object",
"additionalProperties": {
"type": "number",
"format": "double"
},
"example": {
"objectType1": 1,
"objectType2": 0.5
},
"propertyNames": {
"$ref": "#components/schemas/ObjectType",
"enum": [
"OBJECT_TYPE1",
"OBJECT_TYPE2",
]
}
},
"ObjectType": {
"$ref": "#components/schemas/ObjectType",
"enum": [
"OBJECT_TYPE1",
"OBJECT_TYPE2",
]
}
System information (optional)
- OpenAPI v3.1.0
- pnpm v10.13.1
- hey-api/openapi-ts v0.87.5
Metadata
Metadata
Assignees
Labels
bug 🔥Broken or incorrect behavior.Broken or incorrect behavior.