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

Add authentication for remote $ref

Open BozhidaraGYG opened this issue 4 years ago • 3 comments
trafficstars

I have been trying to generate a pydantic model. One of the schemas has a remote $ref to an api that uses Basicauth. So it keeps failing :/

It would be great if one can pass auth parameters, e.g. like in swagger-codegen to access remote endpoints.

Thanks

BozhidaraGYG avatar Aug 09 '21 09:08 BozhidaraGYG

@BozhidaraGYG Thank you for creating this issue. That's a great suggestion.

I will implement it!

koxudaxi avatar Aug 09 '21 18:08 koxudaxi

@BozhidaraGYG I have released a new verison 0.11.12 The version supports --http-headers option. You can give HTTP headers to the CLI.

$ datamodel-codegen --input input.json  --http-headers  'Authorization: Basic dXNlcjpwYXNz'  'X-API-key: abcefg'

koxudaxi avatar Aug 27 '21 16:08 koxudaxi

@BozhidaraGYG I have released a new verison 0.11.12 The version supports --http-headers option. You can give HTTP headers to the CLI.

$ datamodel-codegen --input input.json  --http-headers  'Authorization: Basic dXNlcjpwYXNz'  'X-API-key: abcefg'

Amazing. Can't wait to try

BozhidaraGYG avatar Aug 30 '21 07:08 BozhidaraGYG