# README

OpenAPI Code Generation Example

This directory contains an example server using our code generator which implements the OpenAPI petstore-expanded example.

This is the structure:

  • api/: Contains the OpenAPI 3.0 specification
  • api/petstore/: The generated code for our pet store handlers
  • internal/: Pet store handler implementation and unit tests
  • cmd/: Runnable server implementing the OpenAPI 3 spec.

To generate the handler glue, run:

go run cmd/oapi-codegen/oapi-codegen.go --package petstore examples/petstore-expanded/petstore-expanded.yaml  > examples/petstore-expanded/petstore.gen.go

# Packages

No description provided by the author
This is an example of implementing the Pet Store from the OpenAPI documentation found at: https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/petstore.yaml The code under api/petstore/ has been generated from that specification.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

NewAddPetRequest calls the generic AddPet builder with application/json body.
NewAddPetRequestWithBody generates requests for AddPet with any type of body.
Creates a new Client, with reasonable defaults.
NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling.
NewDeletePetRequest generates requests for DeletePet.
NewFindPetByIDRequest generates requests for FindPetByID.
NewFindPetsRequest generates requests for FindPets.
ParseAddPetResponse parses an HTTP response from a AddPetWithResponse call.
ParseDeletePetResponse parses an HTTP response from a DeletePetWithResponse call.
ParseFindPetByIDResponse parses an HTTP response from a FindPetByIDWithResponse call.
ParseFindPetsResponse parses an HTTP response from a FindPetsWithResponse call.
WithBaseURL overrides the baseURL.
WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client.
WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request.

# Structs

No description provided by the author
Client which conforms to the OpenAPI3 specification for this service.
ClientWithResponses builds on ClientInterface to offer response payloads.
No description provided by the author
Error defines model for Error.
No description provided by the author
FindPetsParams defines parameters for FindPets.
No description provided by the author
NewPet defines model for NewPet.
Pet defines model for Pet.

# Interfaces

The interface specification for the client above.
ClientWithResponsesInterface is the interface specification for the client with responses above.
Doer performs HTTP requests.

# Type aliases

AddPetJSONRequestBody defines body for AddPet for application/json ContentType.
ClientOption allows setting custom parameters during construction.
RequestEditorFn is the function signature for the RequestEditor callback function.