datamodel-code-generator icon indicating copy to clipboard operation
datamodel-code-generator copied to clipboard

Auto-generated top-level text must include the `@generated` word (with `@` prepended).

Open simon-liebehenschel opened this issue 2 years ago • 2 comments
trafficstars

Is your feature request related to a problem? Please describe.

Let's start with an example how other people use this. If you will take a look at https://github.com/koxudaxi/datamodel-code-generator/blob/master/poetry.lock#L1 you will see:

# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand.

The @generated mark is described at https://generated.at/

Describe the solution you'd like

Prepend @ to the "generated" word.

Example:

# @generated by datamodel-codegen:
#   filename:  api.yaml
#   timestamp: 2023-10-06T07:55:02+00:00

simon-liebehenschel avatar Oct 06 '23 07:10 simon-liebehenschel

@AIGeneratedUsername Thank you for suggesting the changes. I wasn't familiar with the @generated tag. Is it a standard in the generator world?

If someone has any thoughts on the advantages or disadvantages of adopting this, please feel free to share your opinions or vote.

koxudaxi avatar Oct 06 '23 16:10 koxudaxi

It is widely used. However, not sure if we can call it a standard. https://generated.at/ tries to make it one. It is easier to recognize for tooling, though, compared to not adding the @ in front.

I was about to file a PR to suggest the same change.

A workaround so far is to use the following argument

--custom-file-header '# @generated by datamodel-codegen'

(Generally, I already use --disable-timestamp as it would cause issues with checks verifying that there are no missing generator changes otherwise.)

pjungermann avatar Dec 11 '23 16:12 pjungermann