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

Add .t in spec generation of Elixir structs #8159

Merged
merged 6 commits into from
Jan 25, 2021

Conversation

carrascoacd
Copy link
Contributor

@carrascoacd carrascoacd commented Dec 11, 2020

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.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. 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*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

I'm unable to run the generate-samples.sh due to an error when generating the JAR file:

[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.5:report (jacoco-site) on project openapi-generator: An error has occurred in JaCoCo report generation. Error while creating report: null: EOFException -> [Help 1]

cc/ @mrmstn

@carrascoacd carrascoacd marked this pull request as draft December 11, 2020 10:49
@mrmstn
Copy link
Contributor

mrmstn commented Dec 14, 2020

Hi @carrascoacd, thank you very much for your PR

Sadly, the error doesn't say a lot to me :/

Have you tried ./run-in-docker.sh ./bin/generate-samples.sh bin/configs/elixir.yaml to generate the examples?

@wing328
Copy link
Member

wing328 commented Dec 14, 2020

Updated samples via 2ab4ceb

@carrascoacd
Copy link
Contributor Author

carrascoacd commented Dec 14, 2020

@mrmstn I was able to update the Petstore as you said using Docker. Maybe we can improve the contribution guidelines in order to add that step.

The outputs from the last commit from @wing328 are the same I got. Many thanks!

@carrascoacd carrascoacd marked this pull request as ready for review December 14, 2020 12:26
@carrascoacd
Copy link
Contributor Author

I think that the deserialization is not right, see this

It should expect the struct, not the type if I'm right.

@wing328
Copy link
Member

wing328 commented Dec 14, 2020

|> deserialize(:"anytype_1", :struct, OpenapiPetstore.Model.Map.t, options)

What does the correct code look like?

@carrascoacd
Copy link
Contributor Author

Let's see this example:

defmodule Pet do
  @type t :: %Pet{name: String.t()}

  defstruct [:name]
end
iex(0)> struct(Pet.t)
** (UndefinedFunctionError) function Pet.t/0 is undefined or private
    Pet.t()
iex(1)> struct(Pet)
%Pet{name: nil}

It should be: |> deserialize(:"anytype_1", :struct, OpenapiPetstore.Model.Map, options)

@wing328 wing328 modified the milestones: 5.0.0, 5.0.1 Dec 21, 2020
@carrascoacd
Copy link
Contributor Author

carrascoacd commented Dec 30, 2020

I was revising this, and I think that the problem is the isPrimitiveType which is returning true for Map when it should return false since it is a primitive type. @mrmstn could you help me to understand why it happens?

There is some coupling between the spec definition and the type definition somewhere.

@mrmstn
Copy link
Contributor

mrmstn commented Jan 8, 2021

Hi @carrascoacd, sorry for my late replay.
I need to look into it a little bit further.

In the mean time, could you explain a little bit, what you're trying to fix with this issue?
What was the "trigger" for this PR?

@mrmstn
Copy link
Contributor

mrmstn commented Jan 8, 2021

image
org/openapitools/codegen/DefaultCodegen.java:3380

Thanks for the tip with the primitiv types. It looks like the anytype_* and map are handled differentially ..

I'm investigating a little bit more, just wanted to let you know I'm on it and see your problem :) - so there is no need for an answer on my question

@mrmstn
Copy link
Contributor

mrmstn commented Jan 8, 2021

@carrascoacd since I'm only in the tech comitee I can't write to your branch, so I created a PR carrascoacd#1

After that, every thing looks good to me and hopefully @wing328 can merge this fix

@carrascoacd
Copy link
Contributor Author

Ok many thanks for taking a look @mrmstn

@carrascoacd
Copy link
Contributor Author

carrascoacd commented Jan 22, 2021

@mrmstn helped me with this and we merged his changes from carrascoacd#1 into this branch. I think we are good to merge now if the pipeline passes :) @wing328

@wing328
Copy link
Member

wing328 commented Jan 25, 2021

Pushed 260feb5 to fix the CircleCI failure. Will merge if all tests pass.

@wing328
Copy link
Member

wing328 commented Jan 25, 2021

Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
  mime 1.5.0
  poison 3.1.0
  tesla 1.4.0
All dependencies are up to date
[INFO] 
[INFO] --- exec-maven-plugin:1.2.1:exec (test) @ ElixirPetstoreClientTests ---
...

Finished in 0.5 seconds
3 tests, 0 failures

Randomized with seed 420535

Tested locally and the result is good.

@wing328 wing328 merged commit cb530d4 into OpenAPITools:master Jan 25, 2021
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.

None yet

3 participants