openapi-processor / openapi-processor-spring

an OpenAPI 3.0 & 3.1 interface & model java code generator for Spring Boot
https://docs.openapiprocessor.io
Apache License 2.0
40 stars 9 forks source link

better mapping format #102

Closed hauner closed 4 years ago

hauner commented 4 years ago

the mapping uses multiple pairs of keywords to define the the different mappings:

  types:
    - from: ..
      to: ..

  parameters:
    - name: ..
      to: ..

    - add: ..
      as: ..

  responses:
    - content: ..
      to: ...

This is getting confusing. Looking for a better idea to handle the different cases with less keywords.

hauner commented 4 years ago

maybe use source/target or in/out to reuse the same keywords. That doesn't work for the add parameter case. Hmm.

hauner commented 4 years ago

spring boot gateway configuration uses something like this:

    predicates:
      - Path=/**

or

    predicates:
    - name: Cookie
      args:
        name: mycookie
        regexp: mycookievalue
hauner commented 4 years ago

considering something like this:

map:

  # single wrapper, maybe without the "=>"
  single: => <to>

  # multi wrapper
  multi: => <to>

  # result wrapper
  result: => <to>

  # list of global mappings
  types:
   # standard type mapping
    - type: <from> => <to>
    - type: <from2> => <to2>

  # list of global parameter mappings
  parameters:
    # map by parameter name
    - name: <name> => <to>

    # add parameter
    - add: <name> => <to>

  # map by content type
  responses:
    - content: <content> => <to>

a few examples:

map:
  result: org.springframework.http.ResponseEntity

  types:
    - type: Pageable => org.springframework.data.domain.Pageable

  parameters:
    - name: pageable => org.springframework.data.domain.Pageable
    - add: request => javax.servlet.http.HttpServletRequest

  responses:
    - content: application/json => org.springframework.data.domain.Page<java.lang.String>