Comments (4)
If you pass an object that's a Dataclass or contains a Marshmallow Schema in attribute __marshmallow__
it'll be able to identify it and generate the schema.
from dataclasses import dataclass
from openapi_specgen import OpenApiParam
@dataclass
class Foo():
bar: str
param = OpenApiParam('test_param', 'query', Foo)
param.as_dict()
# Generated output for this OpenApiParam
#{'required': True, 'name': 'test_param', 'in': 'query', 'schema': {'$ref': '#/components/schemas/Foo', 'title': 'Test_Param'}}
from openapi-specgen.
I do understand that this is how you generate schema for various objects, however this is not the case i was talking about.
I want to describe a param's properties in the case it isn't an object.
Few examples (In yaml since i took them from website):
A string parameter with a format of uuid
- in: header name: X-Request-ID schema: type: string **format: uuid** required: true
An integer parameter whose value is an enum:
- in: cookie name: debug schema: type: integer **enum: [0, 1]**
An integer parameter with minimum value:
- in: query name: offset schema: type: integer minimum: 0 default: 0 required: false
from openapi-specgen.
Oh, sorry, I misunderstood.
Currently format is supported only by type. Meaning specific types have specific formats (date and datetime).
We can add a optional parameter format
, if specified it'll be set as the format in the schema for that param.
Does that work for you ?
from openapi-specgen.
Expected way to do this in 1.0.0 is using a custom type and a custom resolver.
from openapi-specgen.
Related Issues (5)
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 openapi-specgen.