Skip to content

[crystal-lang] Various fixes for Crystal client #21011

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

Merged
merged 10 commits into from
Apr 2, 2025

Conversation

n-rodriguez
Copy link
Contributor

@n-rodriguez n-rodriguez commented Apr 2, 2025

Hi there!

  • fix(crystal): enable some API tests, mark others as pending
  • fix(crystal): dry tests
  • fix(crystal): use Spectator shard to run tests (described_class is not available in Crystal std lib)
  • fix(crystal): wrap rescue in a begin
  • fix(crystal): add isKeyInCookie in Crystal configuration.mustache
  • fix(crystal): various fixes for partial_oneof_module.mustache Crystal template
  • fix(crystal): fix typos in Crystal templates

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

… template

1. `class << self` doesn't exist in Crystal, you must prefix class methods with `self.`
2. use double quotes for String litterals (simple quotes are for Char litterals)
3. global `private` keyword doesn't exist in Crystal, you must prefix private methods with `private`
4. you must specify types when using `each_with_object({})`
@n-rodriguez n-rodriguez changed the title Various fixes for Crystal client [crystal-lang] Various fixes for Crystal client Apr 2, 2025
@wing328
Copy link
Member

wing328 commented Apr 2, 2025

thanks for the PR

cc @cyangle (2021/01)

@wing328
Copy link
Member

wing328 commented Apr 2, 2025

https://github.com/OpenAPITools/openapi-generator/actions/runs/14209017742/job/39822201170?pr=21011

please follow step 3 to update the samples

(if you're using windows, you may need to use WSL to run the command)

@wing328
Copy link
Member

wing328 commented Apr 2, 2025

in the description, can you please list out the bug fixes, enhancements in point form?

@wing328 wing328 added this to the 7.13.0 milestone Apr 2, 2025
@wing328
Copy link
Member

wing328 commented Apr 2, 2025

i got errors running the tests locally (while these tests are running fine in the master)

Showing last frame. Use --error-trace for full trace.

In spec/spec_helper.cr:12:1

 12 | require "spectator"
      ^
Error: can't find file 'spectator'

If you're trying to require a shard:
- Did you remember to run `shards install`?
- Did you make sure you're running the compiler in the same directory as your shard.yml?

does it work for you locally with your own tests?

@n-rodriguez
Copy link
Contributor Author

does it work for you locally with your own tests?

you need to run shards install first to update shard.lock

@wing328
Copy link
Member

wing328 commented Apr 2, 2025

@n-rodriguez
Copy link
Contributor Author

    --without-development            Does not install development dependencies.

@wing328
Copy link
Member

wing328 commented Apr 2, 2025

ah ok

can you please remove that line in the pom as part of this PR?

@wing328
Copy link
Member

wing328 commented Apr 2, 2025

ran the tests again and most passed except the following:

.....................................................................FF.....................

Failures:

  1) Petstore::Pet#from_json should raise error when instantiating a new instance from json string with missing required properties
     Failure: `Petstore::Pet.from_json("{\"photoUrls\": []}")` raised JSON::SerializableError, but the message is not "Missing JSON attribute: name"

          expected type: JSON::SerializableError
            actual type: JSON::SerializableError
       expected message: "Missing JSON attribute: name"
         actual message: Missing JSON attribute: name
                           parsing Petstore::Pet at line 1, column 1

     # spec/models/pet_spec.cr:43

  2) Petstore::Pet#from_json should raise error when instantiating a new instance from json string with required properties set to null value
     Failure: `Petstore::Pet.from_json("{\"name\": null, \"photoUrls\": []}")` raised JSON::SerializableError, but the message is not "Expected String but was Null"

          expected type: JSON::SerializableError
            actual type: JSON::SerializableError
       expected message: "Expected String but was Null"
         actual message: Expected String but was Null at line 1, column 14
                           parsing Petstore::Pet#name at line 1, column 2

     # spec/models/pet_spec.cr:52

i think you will need to update the tests accordingly after switching to spectator

@n-rodriguez
Copy link
Contributor Author

i think you will need to update the tests accordingly after switching to spectator

It's already fixed :) run a git pull --rebase to get the fix

@wing328
Copy link
Member

wing328 commented Apr 2, 2025

all tests passed

............................................................................................

Finished in 21.27 milliseconds
92 examples, 0 failures

Thanks for the contribution 👍

@wing328 wing328 merged commit c4a6c4a into OpenAPITools:master Apr 2, 2025
11 checks passed
@n-rodriguez
Copy link
Contributor Author

Thank you!

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

Successfully merging this pull request may close these issues.

2 participants