Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot generate code with HTTP response code not enclosed in quoted marks #47

Closed
kianmeng opened this issue May 5, 2024 · 2 comments
Closed

Comments

@kianmeng
Copy link
Contributor

kianmeng commented May 5, 2024

Spec file: https://raw.githubusercontent.com/typesense/typesense-api-spec/master/openapi.yml

mix api.gen default openapi.yml 2>&1 | tee -a error_output
03:00:00.044 [debug] Beginning code generation
Profile: "default"
Files: [
  "openapi.yml"
]


03:00:00.049 [debug] Reading file openapi.yml
** (FunctionClauseError) no function clause matching in String.match?/2

    The following arguments were given to String.match?/2:

        # 1
        200

        # 2
        ~r/^[1-5]XX$/

    Attempted function clauses (showing 1 out of 1):

        def match?(+string+, +regex+) when -is_binary(string)-

    (elixir 1.16.0) lib/string.ex:2599: String.match?/2
    (oapi_generator 0.1.0) lib/open_api/spec/path/operation.ex:138: anonymous fn/2 in OpenAPI.Spec.Path.Operation.decode_responses/2
    (stdlib 5.2) maps.erl:416: :maps.fold_1/4
    (oapi_generator 0.1.0) lib/open_api/reader/state.ex:111: OpenAPI.Reader.State.with_path/4
    (oapi_generator 0.1.0) lib/open_api/spec/path/operation.ex:62: OpenAPI.Spec.Path.Operation.decode/2
    (oapi_generator 0.1.0) lib/open_api/reader/state.ex:111: OpenAPI.Reader.State.with_path/4
    (oapi_generator 0.1.0) lib/open_api/spec/path/item.ex:46: OpenAPI.Spec.Path.Item.decode/2
    (oapi_generator 0.1.0) lib/open_api/reader/state.ex:111: OpenAPI.Reader.State.with_path/4
    (oapi_generator 0.1.0) lib/open_api/spec.ex:147: anonymous fn/2 in OpenAPI.Spec.decode_paths/2
    (stdlib 5.2) maps.erl:416: :maps.fold_1/4
    (oapi_generator 0.1.0) lib/open_api/reader/state.ex:111: OpenAPI.Reader.State.with_path/4
    (oapi_generator 0.1.0) lib/open_api/spec.ex:74: OpenAPI.Spec.decode/2
    (elixir 1.16.0) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
    (oapi_generator 0.1.0) lib/open_api/reader.ex:104: OpenAPI.Reader.run/1
    (oapi_generator 0.1.0) lib/open_api.ex:49: OpenAPI.run/2
    (mix 1.16.0) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.16.0) lib/mix/cli.ex:96: Mix.CLI.run_task/2
    /home/foobar/.asdf/installs/elixir/1.16.0-otp-26/bin/mix:2: (file)

I have also reported the issue to the spec file provider.

It worked for https://github.com/OpenAPITools/openapi-generator, but not open-api-generator at this moment.

@aj-foster
Copy link
Owner

Hi there 👋🏼

Thanks for the report. This is an unfortunate, but understandable, issue with the spec. Release 0.1.1 includes a fix to allow for integer-encoded HTTP status code keys.

Thanks again!

@kianmeng
Copy link
Contributor Author

🥳 🥳 🥳 🥳 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants