Comments (8)
bonus fact: I also intended to use this for a nice, shared "pagination" definition for all fetching endpoints
by defining this
components:
parameters:
Pagination:
name: pagination
in: query
schema: { $ref: "#/components/schemas/Pagination" }
explode: true
style: form
schemas:
Pagination:
type: object
properties:
page: { type: number, default: 1 }
perPage: { type: number, default: 50 }
I was hoping I could just add "pagination" like that
/users:
get:
operationId: getUsers
parameters:
- name: filter
# some filter schema here #
# ...
- $ref: "#/components/parameters/Pagination"
from swift-openapi-generator.
Verified that this gets resolved by #226.
from swift-openapi-generator.
The new URIEncoder/Decoder should hopefully lead to this being addressed relatively soon. #192
from swift-openapi-generator.
Verified that this gets resolved by #226.
Great I will have a try. Thank you for your job
from swift-openapi-generator.
@wangzhizhou You'll need to also override the branch of swift-openapi-runtime
to hd-uri-encoder-integration
until it's all landed.
from swift-openapi-generator.
since the docs suggest that "in: query + style: form + exploded: true" is supported I stumbled over this when writing a new server (slack thread)
I was going by this example from the swagger docs:
Objects can be serialized as:
form – /points?color=R,100,G,200,B,150 or /points?R=100&G=200&B=150, depending on the explode keyword
my desired route would look like this:
/users:
get:
operationId: getUsers
parameters:
- name: filter
in: query
schema:
type: object
properties:
name: { type: string }
group: { type: string }
role: { type: string }
explode: true
style: form
however, the generated code produces an error around the conversion:
error: instance method 'setQueryItemAsText(in:name:value:)' requires that 'Operations.getUsers.Input.Query.filterPayload' conform to '_StringConvertible'
try converter.setQueryItemAsText(
in the generated deserializer code (UniversalServer extension)
func getUsers(request: Request, metadata: ServerRequestMetadata) async throws -> Response {
try await handle(
request: request,
with: metadata,
forOperation: Operations.getUsers.id,
using: APIHandler.getUsers,
deserializer: { request, metadata in let path: Operations.getUsers.Input.Path = .init()
let query: Operations.getUsers.Input.Query = .init(
filter: try converter.getOptionalQueryItemAsText(
in: metadata.queryParameters,
name: "filter",
as: Operations.getUsers.Input.Query.filterPayload.self
)
)
in addition of this being a really useful feature, it feels to me that the docs are incorrectly suggesting that this is supported.
edit: just realized the docs do state that only primitive and array is supported, I just didn't rtfm correcly ; )
from swift-openapi-generator.
I use the package:
.package(url: "https://github.com/czechboy0/swift-openapi-generator.git", branch: "hd-uri-encoder-integration")
from swift-openapi-generator.
Thx, it works!
from swift-openapi-generator.
Related Issues (20)
- Null property type with quotes not generated HOT 14
- Support for XML request body and response body HOT 7
- Support schemas.type: string, format: uri generates URL property not String HOT 3
- How to support OAuth2 Password flows? HOT 3
- allOf plus properties HOT 2
- OpenAPI shared components HOT 4
- bug/regression: latest yams results in incomplete generation of types HOT 10
- Logging and HTTPBody HOT 3
- Merging oneOf with many compatible enums of a single value HOT 10
- anyOf encoder does not include discriminator's `parameterName` leading to incorrect encoding HOT 2
- Is there a workaround to deal with slow compilation times for a very large openapi file? HOT 3
- Empty arrays are omitted from query params HOT 5
- Support for `multipart/mixed`? HOT 1
- When a delete path do not have responses content an error generated HOT 2
- Add ability to attach protocols to generated models HOT 9
- Protocol where each `Output` conforms to HOT 3
- Make the generator usable on very big specs HOT 3
- Old and new examples HOT 3
- visionOS can't use HOT 4
- How to convert the binary obtained from the server into a playable Data type? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-openapi-generator.