ex_openai icon indicating copy to clipboard operation
ex_openai copied to clipboard

Support OpenAPI 3.1.0

Open pauldemarco opened this issue 4 months ago • 3 comments

It looks like OpenAI is now publishing new specs at version 3.1.0, which use a lot of "const" and other things. This library will need updated to support the latest.

Here is the updated task with the new link:

defmodule Mix.Tasks.UpdateOpenaiDocs do
  @moduledoc """
  Updates OpenAI API documentation files
  """

  use Mix.Task

  @impl Mix.Task

  @target_dir "lib/ex_openai/docs"
  def run(_) do
    File.mkdir_p!(@target_dir)
    docs_url = "https://app.stainless.com/api/spec/documented/openai/openapi.documented.yml"
    System.cmd("curl", ["-L", docs_url, "-o", "#{@target_dir}/docs.yaml"])
  end
end

Tests no longer pass against this new version.

pauldemarco avatar Aug 07 '25 01:08 pauldemarco

Thanks for reporting! I started with a v2 rewrite that revamps the entire parser into smaller moduels to make changes like this easier but haven't finished yet - https://github.com/dvcrn/ex_openai/tree/v2-rewrite, https://github.com/dvcrn/ex_openai/blob/v2-rewrite/docs/parsingv2.md

It's mostly functional but still missing some handling of type parsing around the api client to use proper structs

The v2 is already using the new API path - https://github.com/dvcrn/ex_openai/blob/v2-rewrite/lib/mix/tasks/update_openai_docs.ex

dvcrn avatar Aug 07 '25 07:08 dvcrn

Curious, why not use some existing OpenAPI parser like spex or apical?

pauldemarco avatar Aug 07 '25 12:08 pauldemarco

Because I didn't know those existed 😄

Good point, I'll check if those make life easier

dvcrn avatar Aug 07 '25 14:08 dvcrn