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

Fix generate crash when have some unknown field #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wingyplus
Copy link

Found by accidentally add $schema to the json for autocompletion
reason. The Tesla.OpenApi.Spec.models/1 at line 278 will crash because
of for iterate defs over map which's cause schema to be the value of
field $schema. Fixes by filter only schema that is map.

Found by accidentally add `$schema` to the json for autocompletion
reason. The `Tesla.OpenApi.Spec.models/1` at line 278 will crash because
of for iterate `defs` over map which's cause `schema` to be the value of
field `$schema`. Fixes by filter only schema that is map.
@wingyplus
Copy link
Author

This is error that I found:

Compiling 1 file (.ex)

== Compilation error in file lib/diablo_clone.ex ==
** (FunctionClauseError) no function clause matching in Access.get/3    
    
    The following arguments were given to Access.get/3:
    
        # 1
        "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"
    
        # 2
        "title"

        # 3
        nil

    Attempted function clauses (showing 5 out of 5):

        def get(-%module{} = container-, +key+, +default+)
        def get(+map+, +key+, +default+) when -is_map(map)-
        def get(+list+, +key+, +default+) when -is_list(list)- and -is_atom(key)-
        def get(+list+, +key+, +_default+) when -is_list(list)-
        def get(-nil-, +_key+, +default+)

    (elixir 1.13.4) lib/access.ex:283: Access.get/3
    (tesla_openapi 0.1.0) lib/tesla/openapi/spec.ex:281: anonymous fn/2 in Tesla.OpenApi.Spec.models/1
    (stdlib 3.17.2) maps.erl:410: :maps.fold_1/3
    (tesla_openapi 0.1.0) lib/tesla/openapi/spec.ex:278: Tesla.OpenApi.Spec.models/1
    (tesla_openapi 0.1.0) lib/tesla/openapi/spec.ex:202: Tesla.OpenApi.Spec.new/1
    (tesla_openapi 0.1.0) lib/tesla/openapi.ex:120: Tesla.OpenApi.generate/2
    (tesla_openapi 0.1.0) expanding macro: Tesla.OpenApi.__using__/1
    lib/diablo_clone.ex:2: DiabloClone (module)

@wingyplus
Copy link
Author

This is openapi file that I found an error: diablo_clone.zip

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

Successfully merging this pull request may close these issues.

1 participant