Help structuring the components section

Having some trouble using the components section of the openai.yaml file, plugin works without it but I’m sure it adds great functionality. Wondering if there is any guides or discussions which cover best practices for the components section?

My understanding is that it’s just a way of keeping the yaml DRY (Don’t Repeat Yourself).

So if you have some structure that is returned from multiple endpoints, instead of repeating it each time, you can refer to a component and only write it once.

You can see an example in my chess plugin yaml: ChessGPT/openapi.yaml at main · atomic14/ChessGPT · GitHub

ChatGPT is actually pretty good at generated the openapi spec - I’ve often just copy and pasted my flask API into it and asked it for the spec (obviously only works for small files). But you can also just describe the API and get it do it.

3 Likes

That’s helpful! Thank you. Additional to your example, I’ve found it best to look at others examples. This website is great to see submitted plugins and their openai.yaml structure: https://www.gptplugins.app/.

Haven’t tried using chatGPT to generate but will give that a go, I’m sure it would be improved if you can share some documentation as well but token limits are a consideration.

I would also encourage the use of the swagger-cli tool or tools like it to bundle your openapi.yaml file. The bundled version of mine is around 2,500 lines which quickly I saw as unmaintainable. So I separate out all paths, parameters and schemas into their own folders and then before prod push, I bundle them into one compiled openapi.yaml. Helps to big larger projects while maintaining sanity

Chase W. Norton

2 Likes

Try my plug-in bot. You can use it with GPT-4, it can also help debug.