Closed anuraggo closed 3 years ago
@anuraggo Again, sorry for the delay. We recently merged in #399 (see #379 for the discussion). This adds the ability to add extensions in the OAS to define custom type and field names.
To clarify, appending numbers is intended when multiple types or fields share the same "preferred" name, aka the derived name from references, properties, etc. Most likely there is another type in your generated GraphQL interface that has the name Note
.
I need to make a new release but the extensions are your recommended solution.
Edit: Try v2.4.0 and see the following: https://github.com/IBM/openapi-to-graphql/tree/master/packages/openapi-to-graphql#custom-type-and-field-names-and-enum-values
Hello @Alan-Cha ,
Thanks for your reply.
Usage of OAS extensions needs updating the swagger schema annd I don't have that option to update it.Hence I have tried writing below wrapper to modify the OAS js-object to insert the extension before invoking the method createGraphQLSchema. It is updating the oas object properly but not in the graphql schema .
const definitions = oass[oasKey].definitions || {}; Object.keys(definitions).forEach(definitionName => { oass[oasKey].definitions[definitionName] = { ...oass[oasKey].definitions[definitionName], 'x-graphql-type-name': definitionName + '_responseSuffix' } });
This is updating the oas object as :
SystemListValue: { type: 'object', properties: { name: [Object], validFor: [Object], localizedName: [Object], displayProperties: [Object] }, description: 'Single valid value of a list.', 'x-graphql-type-name': 'SystemListValue_responseSuffix' }
But the final graphql output schema is not appending the suffix for all the types.
Hello,
Is there any way we can add a suffix/prefix to the model Definitions like below:
type_responseSuffix {
}
Also, I have observed that openapi-to-graphql appends number to the defintions name such as Note2 May I know how can we omit this or bypass If I want to display only Note ? @Alan-Cha Can you please help me here ?