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

[Help/debugging] POST headers & body not being generated #9

Open
nikspyratos opened this issue Sep 18, 2023 · 3 comments
Open

[Help/debugging] POST headers & body not being generated #9

nikspyratos opened this issue Sep 18, 2023 · 3 comments
Labels
good first issue Good for newcomers

Comments

@nikspyratos
Copy link

nikspyratos commented Sep 18, 2023

👋 Heyo! Finally got around to working on more of my banking sdk. Thought I'd make an issue for investigation instead of going on socials just for better visibility/tracking.

I'm using the OpenAPI specification files from the bank's API, for example this one. On that page you'll see a download button for the OpenAPI file that I'm using with the generator.

The generator generates all the requests, connectors, etc. correctly. The issues I'm having are that some headers and POST bodies are not being populated in the requests. I'm going to assume this is due to the OpenAPI spec file being quirky and having more complex specs maybe?

Let's take the Post Category request for example. The generated CreateCategory request class is bare:

Screenshot 2023-09-18 at 22 16 23

Meanwhile, the Swagger editor seems to pick the header & body up correctly:

Screenshot 2023-09-18 at 22 17 29

All requests in this api also require an intermediaryId header value, but this is not picked up in any of the generation.


Command-wise, what I'm running is:

sdkgenerator generate:sdk ~/Downloads/CIBForIntermediaries.json --type=openapi --namespace=InvestecSdkPhp

Any ideas? Is the OpenAPI spec file being weird, or am I doing something wrong?

@HelgeSverre
Copy link
Member

Ahh, this package currently don't support header values.

Want to try to tackle this in a PR, what specifically has to be done is to add a "headers" array to the Endpoint class similarly to how we do it for these:

// ...
public array $queryParameters = [],
public array $pathParameters = [],
public array $bodyParameters = [],
// ...

Then in the OpenAPI parser it has to be parsed out from the Operation (i'm assuming), here:

https://github.com/crescat-io/saloon-sdk-generator/blob/master/src/Parsers/OpenApiParser.php#L75-L78

Then add code generation in the RequestGenerator, around here-ish:

https://github.com/crescat-io/saloon-sdk-generator/blob/master/src/Generators/RequestGenerator.php#L87

I think this one might be fairly simple to implement (famous last words nervous laughter)

@HelgeSverre HelgeSverre added the good first issue Good for newcomers label Sep 18, 2023
@nikspyratos
Copy link
Author

Oooh noice, will have a go at it for the headers.

Any idea for the body?

@tuarrep
Copy link

tuarrep commented Mar 18, 2024

I think the issue about the body is related to #21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants