feat: add support for schema keywords by cowboy-bebug · Pull Request #2162 · oapi-codegen/oapi-codegen
Hi there 👋
I use the tool extensively at work and thought it'd be really great to generate some consts based on the JSON schema keywords.
This PR adds features to handle the keywords such as minimum, maximum, etc.:
paths: /users: get: operationId: listUsers summary: List users with pagination and filtering description: Demonstrates inline parameter constraints generating constants parameters: - in: query name: limit description: Maximum number of items to return schema: type: integer minimum: 1 maximum: 100 default: 20 components: schemas: Username: type: string minLength: 3 maxLength: 20 default: "guest"
as constants:
// Constraint constants for ListUsersLimit. const ( ListUsersLimitMinimum int = 1 ListUsersLimitMaximum int = 100 ListUsersLimitDefault int = 20 ) // Constraint constants for Username. const ( UsernameDefault string = "guest" UsernameMinLength uint64 = 3 UsernameMaxLength uint64 = 20 )
I didn't find any relevant / related issues. Let me know if this is something valuable to you guys as well 🙏