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 --quiet option for spec generation #557

Merged
merged 1 commit into from
Aug 18, 2023

Conversation

Cowa
Copy link
Contributor

@Cowa Cowa commented Aug 17, 2023

This PR adds a --quiet option on the spec generation task.
It allows to disable the mix shell printing when creating folders and files.

Useful to avoid pollution if you run the task in tests, for example:

screen

@zorbash
Copy link
Contributor

zorbash commented Aug 17, 2023

@Cowa Makes sense to be able to silence the output of the mix tasks but I'm curious to know what is the purpose of the your tests running these tasks. Can you please explain what you're testing?

@Cowa
Copy link
Contributor Author

Cowa commented Aug 17, 2023

@zorbash We use orval on the front-end, it uses the generated json spec to create a TypeScript client.

The json spec is committed and the test ensures that if the API has changed then the json spec was re-generated.
This way the CI fails if it's not up-to-date.

The test just run the task and compares the generated spec against the committed one.

test "latest API specs should have been generated", %{tmp_path: tmp_path} do
  Mix.Tasks.Openapi.Spec.Json.run([
    "--spec",
    "EmployerBrandingWeb.AnalyticsApiSpec",
    "--start-app=false",
    "--pretty=true",
    tmp_path
  ])

  latest_specs = File.read!(tmp_path)
  local_specs = File.read!("doc_src/api_specs/analytics.json")

  assert latest_specs == local_specs,
          "Run `mix openapi.gen` and commit changes - OpenApi specs have been modified but not re-generated"
end

@Cowa Cowa force-pushed the api-spec-gen-quiet branch from ed1fd29 to 2280c60 Compare August 17, 2023 18:29
@Cowa Cowa force-pushed the api-spec-gen-quiet branch from 2280c60 to 8575005 Compare August 17, 2023 18:30
@zorbash zorbash merged commit 5560d0a into open-api-spex:master Aug 18, 2023
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.

2 participants